everyone. I have an advanced T4 question and I'm hoping someone can help.
I've created a SQL-like DSL, and the scripts are saved in '.satsql' files in my C# projects, like so;
// contents of myqueries.satsql
SELECT <column t1.Id> FROM <table mytable t1>
I have a .tt file which loads the file and attempts to parse it. If it fails, I want to add an error to the Visual Studio error list, like so;
myqueries.satsql (1,8) error: unknown column 'xid' on table 't3'.
myqueries.satsql (2,9) error: bad reference: pid.
When the user clicks on the error, VS should open the 'myqueries.satsql' file and point the cursor at the appropriate line and character, just as it does for C# errors.
T4 already provides the void TextTransform.Error(string) method, but that doesn't seem to give me the opportunity to set the file, line, and character the way C# errors do.
Does anyone know a way for a T4 file to report an error in another file -- not the T4 file itself?
Many thanks,
Steve Cooper.
You can use TextTransformation.Errors collection to report errors with file and line number information.
Related
I understand that there is definitely something wrong with my report (e.g. columns missmatcch) and I need to correct it but what I see is the WCF error message that hides actual problem and exactly this hiding irritates me much more than original problem: columns missmatch.
I guess we need to adjust the WCF 'buffer size' and we will get original problem message. But where is the config file?
Text search of "system.serviceModel" in the C:\Program Files (x86)\Microsoft Visual Studio 10.0 doesn't bring good idea...
P.S. Since this is just preview of report I do not think that it is SSRS configuration problem. Problem localised somewhere in DevStudio process or int the DevStudio's internal web server process ...
P.P.S Please help me too improve the question. I see that responders doesn't understand what kind of help I need.
I have encountered multiple "flavors" of this bug in SSRS Preview. It seems the renderer for Preview mode is quite fragile.
There is a simple way to solve this. Ignore the error and attempt to upload the RDL file to your reporting server. The uploader will happily tell you exactly what is wrong with your file - it will tell you exactly what field has a problem and what that problem is. If there are multiple errors, you will get told each and every field and the error associated with each one.
I can create this bogus XML buffer error with any of the following:
Add a new Tablix, start to connect it to a dataset, then cancel out.
Copy/paste some text into a textbox from a MS Word document where one or more lines have a negative right indent (right column end is outside page margin).
Connect a dataset with a varchar(8000) returned value.
Please Check if any of your report items are referencing fields that are not in existing dataset scope.
This indeed worked for me.
See Below link for more information:
http://connect.microsoft.com/SQLServer/feedback/details/742913/ssdt-reporting-services-designer-error
I have seen this error when adding a new field to an existing dataset by clicking "Refresh Fields".
The dataset source was a stored procedure. The result was only a few of original fields showed up in the dataset field list and not the new field. If I tried to preview the report I get XML buffer error.
Workaround was to not refresh fields but hit add new field and type the new field name into the dataset properties field last.
Worked fine after that.
I got this error again today.
I had created a table to hold data to replace two slow queries. I changed some names to clean up the process.
I think the error actually means that there are so many problems with my report that the buffer holding the various error messages isn't large enough which leads to the error message.
The size necessary to buffer the XML content exceeded the buffer quota
Of course this should be an easy fix but Microsoft has said that they will not fix it.
https://connect.microsoft.com/SQLServer/feedback/details/742913/ssdt-reporting-services-designer-error
EDIT: I've updated my answer based on having fixed the issue.
I'm currently experiencing this problem after having changed multiple stored procedures and updating the dataset names in the SSRS report.
And when I try to run the preview I get the exact same error.
As it turns out, after investigating the issue, the problem was that I had changed the name property of my datasets.
There several places in my report where formulas or expressions use the old name properties of the datasets I renamed. After reverting the dataset names back, I managed to get the real errors like missing fields etc. atcual errors came back after I set my dataset name properties back to what they were.
I only changed the name property back to what it was, the stored procedure names were correctly referring to my renamed stored procedures.
I had this problem when after copying and pasting a tablix, it changed CDbl in a formula to Microsoft.ReportingServices.RdlObjectModel.ExpressionParser.VBFunctions.CDbl. I opened up the XML and removed all instances of "Microsoft.ReportingServices.RdlObjectModel.ExpressionParser.VBFunctions." and the report then worked.
For a working report, when I tried to add a column it gave me this error. I edited the .rdl file using notepad++. After SSRS prompt to reload the change from disk, it worked without issues.
I got this error after copying my Custom Code to Visual Studio for hightlighting the code for better readability. Well, Visual Studio added class definitions to the beginning and end of the file. After editing code, I pasted it back to report Custom Code, then got this error. Fix was just to remove class definitions (Public Class Class1 and End Class) from Custom Code. So, check your Custom Code also (if any).
I got this error after adding some new parameters to an existing report.
For some reason when I created the parameters first then modified the Dataset to use the new parameters I got the error, but when I modified the Dataset first then added the parameters second and I did not get the error.
This seemed like very strange behavior to me so I tested it by restoring the report from repository and repeating the process three times with each method, and had identical behavior every time.
I am also facing this problem. I solve this Find and replace
Microsoft.VisualBasic.Interaction.iif ==> iif
Microsoft.ReportingServices.RdlObjectModel.ExpressionParser.VBFunctions.cdbl
==> cdbl
I hope this may helps someone. Thanks
Possible root causes
Parameter name is incorrect(case/order)
Accessing non-existing property.
and many more...
Solution: To get the exact error message are
Deploy SSRS report and find the error : Suggested by "Kim Crosser" already
Remove the section(SSRS/Report content) temporarily you feel is error free to free space in buffer so that you can get actual error message. Later add sections back to the page(removed earlier).
I had the same error message and it was totally caused by my doing. It's a bit embarrassing, but if it helps someone out then great! I had accidentally copied my dataset query that included a small sub select statement within it, which I was using to check parameter/variable values.
Another solution is to open the .rdl file in Report Builder 3.0 (as opposed to Visual Studio) and try to preview it. I found this gave me the details of the error, although if more than one error is present it only shows the first.
I previously binded a TextBox to
Fields!FieldName
and fixed it with
Fields!FieldName.Value
With that said, and with the other answers posted as well, this error happens in different flavors. My issue was fixed after I had the field property "Value" included.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
In VFP9 I need to move the database to a Netgear ReadyNas Duo V2 shared network drive.
I don't know exactly which files to move or where and how to put the network path.
I've been trying for 2 days and keep getting error 2005 (...."table file users.dbf has moved"....) at start-up and now time is running out.
Although DaveB provided all the extensions, but I think you might be looking for something a little more specific to the data and tables.
In VFP, if you have a database container, you can do it a few ways... have a database located in one folder/path, and the actual TABLES in another path... Not anything I would recommend, but that MAY be what you are encountering. The database will have the path where the tables are EXPECTED to be found when you try to open them.
The other is to have both the database AND the tables in the same folder. There are 3 files for the database itself
.dbc -- database
.dcx -- compound index of database
.dct -- memo field content for database
Additionally, the tables can have up to 3 files each with respective suffixes
.dbf -- single table
.cdx -- compound index for the single table
.fpt -- memo field content for the single table
So, if you have moved the tables from one location to another and they don't have same paths in expected location, that will cause you some headaches. If you have VFP, you can open the database as a table and browse it to see what is expected where. For example
CD Whatever\Your\DataPathIs
use NameOfYourDatabase.dbc (yes, explicitly add the .dbc suffix)
browse for objectType = "Table"
then, if you double-click the "memo" field column for the property, you'll see a bunch of non-viewable characters represented by square boxes and then a path that corresponds to where the database is EXPECTING to find the file.
This might be the missing piece you are looking for.
Hopefully there are no hardcoded file paths anywhere. You might need to recreate the file tree from a specific root. The following looks like a good list of files to look for.
From Visual FoxPro File Extensions and File Types:
File Extensions and File Types used by Visual FoxPro
Extension File type
----------------------------------------------
.act Documenting Wizard action diagram
.app Generated application
.cdx Compound index
.dbc Database
.dbf Table
.dct Database memo
.dcx Database index
.dll Windows Dynamic Link Library
.err Compilation error
.exe Executable program
.fky Macro
.fll FoxPro Dynamic Link Library
.fmt Format File
.fpt Table memo
.frt Report memo
.frx Report
.fxp Compiled program
.hlp Graphical Help
.idx Index, compact index
.krt Used in the recreation of a .dbc file
NOTE: The .KRT extension is not listed in the online Help.
.lbt Label memo
.lbx Label
.lst Documenting Wizard list
.mem Memory variable saveDoslives
.mnt Menu memo
.mnx Menu
.mpr Generated menu program
.mpx Compiled menu program
.ocx OLE control
.pjt Project memo
.pjx Project
.prg Program
.qpr Generated query program
.qpx Compiled query program
.sct Form memo
.scx Form
.spr Generated Screen Program (previous versions of FoxPro only)
.spx Compiled Screen Program (previous versions of FoxPro only)
.tbk Memo backup
.txt Text
.vct Visual class library memo
.vcx Visual class library
.vue FoxPro 2.x view
.win Window file
anybody have any easy way of doing this in Visual Studio, without having to use the Server Explorer ?
I tried also looking at macro's but recording only produce
Sub TemporaryMacro()
End Sub
So no luck there.
Any way to script this?
I am using a batch script similar to this to manage the updating of my models when the underlying tables/views change. To use it:
Have SQLMetal and SQLMetalInclude (you may have to download and build from source) accessible from the current directory (or in the path)
Create a file "chosenEntities.txt" with a table/view name on each line. These tables will be the only ones that code is generated for.
Modify, save and execute the Generate.bat batch code
(Optional) Add the .bat file as an external run tool to Visual Studio, as explained here
Generate.bat:
sqlmetal /conn:"Data Source={Hostname};Initial Catalog={DBName};User ID={Username};Password={Password}" /dbml:temp.dbml /views
setlocal EnableDelayedExpansion
set file=chosenEntities.txt
set include=
FOR /F %%i IN (%file%) DO (
set include=!include!%%i,
)
set include=%include:~0,-1%
sqlmetalinclude -dbml:temp.dbml -output:ChosenEntities.dbml -include:%include%
sqlmetal /context:CustomDataContext /pluralize /namespace:MyNamespace.DB /language:csharp /code:DBEntities.cs /entitybase:DBEntityBase ChosenEntities.dbml
chosenEntities.txt example:
Accounts
Customers
PRODUCTS_VIEW
AnotherTable
Explanation:
Intermediate .dbml file is generated by sqlmetal as usual. The created dbml file contains the definitions for every single table in the database (and views, if selected)
The next code block loops through chosenEntities.txt, and for each line appends the line contents (table name) plus a comma ','
The last trailing comma is removed
Run sqlmetalinclude, which basically makes a copy of the original temp.dbml file, but only including the Tables you specified. There are other options available, like transforming the individual table names
sqlmetal is run a second time, this time generating the actual .cs code based on the cut-down .dbml file.
SqlMetal Include worked like a charm for me.
First Create a complete dbml file using SqlMeta - Say testComplete.dbml
Now provide this file as an input to SqlMetaInclude
SqlMetalInclude /dbml:"testComplete.dbml" /output:"testSubSet.dbml" /include:dbo.SampleTable1=SampleTable1,dbo.SampleTable2=SampleTable2
Note that this tool in has a GUI included which can handle the complete process.
There is one good utility out there which helps you update your existing DBML files from the database: Huagati DBML/EDMX tools.
It's not free, but worth the investment for any serious Linq-to-SQL development.
The only alternative would be to write it yourself - read the database structure and compare that to the XML representation in the DBML, and update the DBML as needed.
I am using T4 for generation of some DTO classes + mappers.
I am splitting the files in a number of re-usable bits (some of which containing common methods, some others common procedures) and including them into the T4 templates that will produce my output - which is all good.
My problem is that the re-usable .tt files will try and produce their own output and fail (because they are coupled to some other .tt files) every time I make a change to them, which plain sucks.
I am pretty sure I saw somewhere some directive to specify a given file shouldn't try and produce any output, but I can't seem to track it back.
Any help appreciated!
You can specify invalid extension to suppress the output of your template, for example:
<## output extension="\n" #>
In the properties (select file and press F4) of the T4 files for which you'd like to suppress output, clear the 'Custom Tool' entry.
I don't have enough 'StackOverflow street cred' to reply to Stanislav Kniazev's answer, so will have to post my own here. Thanks for the lead Stanislav Kniazev.
The following worked; but if you are using a T4 syntax highlighter (like Tangible T4) you will find that it stuffs up the highlighting.
<## output extension="\n" #>
So I found setting the extension to something that is not an escape char like this:
<## output extension="" #>
and then in the code section programmatically setting the file extension, like this:
Host.SetFileExtension("\n");
T4 highlighting is then restored.
rename them to .ttinclude and see how that goes for ya....
I want to understand if code snippets are what I am looking for here.
I wind up writing the same line of code over and over during a refactoring.
Is there anyway I can create a shortcut that will spit out a line of code that I need?
Another easier option is to drag the code blocks that you re-use frequently onto the general tab of your toolbox area. You could even organize them with their own tab name and all.
alt text http://blogs.telerik.com/Libraries/MetaBlog/WindowsLiveWriter-VisualStudioTooltipsunpluggedDragandDro_EF10-generalTabDragged.sflb
Are you repeating the same line of code over and over on many different days?
Or are you encountering a situation where you have the same line to write many times as a part of a single task, but today's line of code will be different to tomorrows?
If you have the same line/block of code that you use often, a snippet is a good way to capture that in a reusable form (better, IMHO, than copy/paste because you can parameterise them).
However, if you're just looking for a quick way to repeat the same line that's come up now, check out Visual Studio's ability to record keystrokes.
Try this:
Put your cursor on a blank line inside a C# method.
Select Tools|Macros|Record Temporary Macro (often this is Control-Shift-R)
Type "example();" and press return
Select Tools|Macros|Stop Recording
You've just created a temporary macro that you can play back at any time - usually the keystroke for this is Control-Shift-P.
The key to this technique is that the macro records everything you do - with some practise, you can record edits to a line of code and repeat those edits on other lines.
I've used this in the past to create repetative code blocks - like assigning sets of properties from one object to another.
Depending on the code snippet, it would almost always be arguable that this line of code belongs in a util method, rather than copypasta.. But otherwise, yeah - a snippet is probably the best place.
Code Snippets sound like the right approach, although you could investigate Macros inside Visual Studio, which can be very powerful.
One advantage of a code snippet over adding it to the toolbox is that you can define the parts of the code that you want to change. I wrote a code snippet that generated something like the following code:
public class *className*Collection : List<*className*>
Where I only typed className once and it was automatically filled into the other parts.