VS2005 Options Generate Method Stub not working - visual-studio-2005

Ok I installed the linq preview(May 2006) and it seems to have screwed me up. Now the one the of the most important features in VS2005 is not working anymore (Options Generate Method Stub (Shift+Alt+F10)). I used to get this message every time I would start a project
("This is an unsupported version of Microsoft Visual C# 3.0 / Microsoft Visual Basic 9.0. Therefor, many features may not work as expected.").
I uninstalled it and the feature is still not working but the error message is gone now.
If you don't know what I'm talking about if you type this simple code in you visual studio code editor: "string myString = GetString();" without declaring GetString() first, you will get a smart tag under GetString() and when you select it, you get a drop down that asks if you want to auto generate this method stub.
Is there a way to re-enable it?

Not sure why you installed this ancient version but did you also properly install dotNet 2?
You may have to re-install by hand.

Related

Debugging SSIS Script task - Breakpoint is enabled but it does not hit

I am working on an SSIS package. The package has a script (C# language) task. I need to debug the script task. I set the break point. The script in script editor (Visual Studio) and the task in SSIS package editor, both, show break point in red color - means the break point is enabled. However, when I debug the package the break point does not hit.
The break point has no conditions on it, so I expect it to hit every time the package runs.
I am using Visual Studio 2008 on Windows 2003 R2 64-bit SP2.
After more research and trial-error, found that the SSIS package ignores the breakpoints in a Script Task when debugging on a 64-bit machine. To fix it -
Go to the Solution Explorer
Right click your SSIS project node > Properties
In Configuration Properties > Debugging > Debug Options > Set Run64BitRunTime to False.
After making this change, the breakpoints hit like magic.
I tried all the answers provided here with no success (using VS2015). After some more searching I found this question that is actually an answer which stated that newer C# features / syntax were causing the debugger to not fire correctly.
In their example (and also mine) using string interpolation was causing the breakpoints to not be hit.
Replacing
$"{someVariable} - {someOtherVariable}"
with
string.Format("{0} - {1}", someVariable, someOtherVariable);
did the trick for me.
EDIT
It appears this issue has now been fixed with SQL Server Integration Services Projects, but you need to be running VS2019 to download it.
Update: Guys, I againg lost any ability to set breakpoints (a request to MS)
My previous fixes are below.
Now I'm using logging and tracing instead of debugging.
C# new features (after C# 4.0) are blamed for killing debugging of the SSIS Script Task.
To return the breakpoint capability I do the following.
Remove C# new features
Run my Script Task once, successfully. I.e. without a crash.
Reopen the Vsta Project from my Script Task and put breakpoints there.
At the end, you have to see a red circle on your Script Task.
(Tested in VS 2017.)
Note. I have to mention that debugging works even if your use "Execute Task" only, not "Execute Package"!
Remove C# new features
To remove the C# new features, I can advise you two ways.
First, restrict Vsta Project properties to C# 4.0 (migrated packages may not support this).
Dobule click your "Script Task" to open "Script Task Editor".
Click "Edit Script..." button to open Visual Studio.
In "Solution Explorer" select the project and click the F4 key on your keyboard.
In opened "Properties" window in "C# Language Level" choise "C# 4.0"
Build your project and fix compilation errors.
Secondly, Vsta Projects in old/migrated packages may not show the above "C# Language Level" property.
So you can put your code in a fake project in Visual Studio 2010 and compile it there.
Run it once successfully
After you fix your C#, you have to run your Script Task once successfully.
You may want to put the return statement at the beginning of the Main() method to prevent any real execution.
Sorry, this doesn't always work and I don't realise why but you definitely need to fix your C# in the first place.
At least you will get a working Script Task and can debug it in an old fashioned way (logs by Dts.Events..., exceptions, etc.)
TL;DR
It looks like I even got severe cases when C# new features forced Script Tasks to fail silently with a success completion status.
As an example, add the following to your Script task.
string Bug { get; } // Only getter properties.
//...
var str = $"Now is {DateTime.Now}"; // String Interpolation in C#
//...
var dummy = val?.ToUpper(); // ?. and ?[] null-conditional Operators
And workarounds for this non-complete list:
string Bug { get; set; }
//...
var str = string.Format("Now is {0}", DateTime.Now);
// etc.
What I also do, I build my C# code in Visual Studio 2010. It simply doesn't compile the new .NET features and do not allows .NET Framework versions above 4.0. So far, so good.
Of course, other answers from this SO-question didn't help me.
In my case, none of these solutions worked. I finally got to know that the Resharper was culprit. After uninstalling it, it started working like charm.
In my case, I had to get rid of all features from C# 6: string interpolation, null conditional operators (?., ?(), ?[]) and expression-bodied members (=>) (there might be more in your case). You can check them all here. Of course, the same applies to C# 7 features.
The 32/64 bit changes from other answers didn't help, so I rolled back those and the debugging kept working just fine.
Use System.Diagnostics.Debugger class to add breakpoint programmatically:
System.Diagnostics.Debugger.Launch();
System.Diagnostics.Debugger.Break();
You can check if the debugger is attached or not:
if (System.Diagnostics.Debugger.IsAttached)
System.Diagnostics.Debugger.Break();
Follow these step:
Keep your project or solution opened.
Run your app to hit breakpoint.
Select your project in Just-In-Time Debugger.
I inherited an SSIS package where unfortunately the above answers didn't help.
In the end I found the script task's build properties for debug mode had had the optimize code ticked. Make sure this isn't ticked because for me visual studio would fire up for script debugging and close shortly after without breaking at all.
Pretty obscure but worth a mention.
We hit the same problem recently. For us the solution was to ensure that the script task project was marked to run as with the platform target set to x86.
Edit the script task
Click on the project and select properties
Select to set the platform target to x86
In addition to Jeff's suggestion, also change the Platform Target to "x86" (In the script's properties' Build tab. This FINALLY got me debugging again on a 64-bit system.
Microsoft released an update v3.2 of SQL Server Integration Services Projects where it resolves the issue with Roslyn and other C# language features introduced after .Net 4.5. C# features.
Bad news - this fix is for Visual Studio 2019 only, you have to upgrade your VS to use it.
I spent whole day on this and NONE of the solutions mentioned here worked for me.
In my case, the existing project was targeted to SQL Server 2016 which defaults ScriptLanguage Microsoft Visual c# 2015. This doesn't allow debugging in VS 2019. I have to target project to SQL Server 2019 to make debugging work. Of course, I am not going to checkin version change. It's only to debug script. Once script is working, I am going to revert target version to SQL server 2016.
Hope this saves time for someone.
I had the same problem as you #PAS. Using VS 2019 and Target server version 2016.
Just found out that if upgrading SSIS in Visual Studio (going into Extensions->Manage Extensions) to latest version (which now is 3.15) debugging is now working.
My breakpoints refused to hit no matter what I did. I ended up debugging and fixing the issues just using exception throws. Once I had fixed the issues I was having, the breakpoints started hitting!
So my breakpoints would only hit once the code did not experience any runtime issues... which is bizarre.
In my experience, it doesn't matter:
if Run64BitRuntime is true or false
if you build the 32 or 64 bits version of your package
But there is something very important, not mentioned in any other answer: you must run the whole package. If you run a Task or a Container the breakpoint will be ignored.
I'm using Visual Studio 2013, on a 64 bits machine.
I only had one Script component were no breakpoints were hit (I was doing some CRM stuff without needing source/target).
I trid to add a Source componenet with a simple fetchXML (even if I didn't needed it).
Then it worked! :-)
I found out that by copying a Script Component task, the VSTA project as a whole is copied as well. This is what you would expect, but what I did not expect is with that, the assembly name for example is also copied.
Running then Execute Task works fine, but running the whole package actually only runs the first script that was copied and resulted in exceptions being thrown before ever hitting the row processing function.
That was also the reason for me that breakpoints were not being hit.

Error message in VS2013 Ultimate edition

I'm getting the following error message
Cannot access a disposed object. Object name: 'MarshalingWindowFrame'.
This message came when I tried to load a SLN file into VS2013.
What is the reason?
I am using VS2013 Ultimate with Update 4 on Windows8.1 pro x64 bit OS (8GB RAM, 500GB HDD)
If you get that when opening a solution, either an addon is bugging out or (worse, but less likely) you found a bug in VS itself. Try safe mode and see if that helps.
If however you get the error when opening a form rather than the solution itself (remember opening a solution loads the various forms), there's a bug in an user control that's trying to access a disposed object. Remember that user controls run as binaries when hosted in VS, so make sure you put actual code inside guards that require you not to be in design mode.
Was that project created in the earlier versions or in the Visual Studio 2013 Preview? Because, if you update this project from Visual Studio 2013 Preview, you have to check the update procedure (http://blogs.msdn.com/b/lightswitch/archive/2013/08/12/upgrading-your-lightswitch-projects-raghuveer-gopalakrishnan.aspx) first, perhaps it can give some hints why this happens.

Querying Language service in Visual Studio Editor Extension to get Assembly, class and method info

I want to write an Editor extension for Visual Studio 2010.
In my extension I want to get information about the Class, method which is at the current caret position.
For example, if I am in an Event Handler and I have some code that shows a MessageBox using MessageBox.show(…) and the caret is at .Show,
I want to query VS Services to get a response which tell me that I the caret is at Show method of MessageBox class which is in System.Windows.Froms.dll version 4.0.40319 etc.
Is it possible?
There is no way to do this with the current APIs in Visual Studio 2010. This is why we're building the Roslyn APIs so you could. When you install the CTP, we setup a Roslyn instance that replaces the standard language services with the Roslyn ones, and you can ask your question directly to it.
If you don't want to be dependent upon running in the Roslyn instance (which I assume is the case), then it gets a bit trickier. You can invoke the parsers to understand you're on a call named MessageBox.Show, but to get the semantics you'd have build up a Compilation making sure you get all the project references and source files right. That's a far trickier proposition, so depending on your scenario you might want to "cheat" as much as possible.
Disclosure: I'm on the Roslyn team.

Issues debugging Moles

I’m using visual studio 2008 and moles version 0.93. Everything works well except when I try to debug any test that uses a Moled type. The test skips all my breakpoints. And I get the following message in the output window:
Unable to attach. Check for one of the following.
The application you are trying to debug uses a version of the Microsoft .NET Framework that is not supported by the debugger.
The debugger has made an incorrect assumption about the Microsoft .NET Framework version your application is going to use.
The Microsoft .NET Framework version specified by you for debugging is incorrect
Please see the Visual Studio .NET debugger documentation for correctly specifying the Microsoft .NET Framework version your application is going to use for debugging.
If I try debbuger.Break () I get a message: "No symbols are loaded for any call stack frame. The source code cannot be displayed."
I’m in a crunch right now chasing an issue with one our main components and it has been a pain (like I need novocaine) trying to figure anything out without being able to step through the code.
I want to take advantage of mole's "smooth debugging experience". However, I can't seem to get the debugger to attach at all.
Thanks,
Bzz
See the solution to this issue here:
http://social.msdn.microsoft.com/Forums/en/pex/thread/91c08bf4-3260-458c-a221-91f030a75499
I had this problem when I moved a project from Visual Studio 2010 to Visual Studio 2008. Here's what I did to fix it.
Close Visual Studio. Navigate to the Debug/bin location. Delete the following files:
*.vshost.exe
*.vshost.exe.config
*.vshost.exe.manifest
Open the solution. Goto the project Settings. Under the Application Target Framework, select a framework lower than the one you are working with (you'll set it back later). Visual Studio will close and re-open your project automatically. Then set the Target Framework back to the original version you were working with. Rebuild all, and debugging will work properly.

Visual Studio 2008 not detecting Errors while coding

I just installed VS on another PC, but this time, while I am coding, it is not marking syntax errors while I am coding..... I need to press F6 to get the errors.
Normally when for example typing the line below, I get 's' underlined saying that there is a mismatch. Any ideas how I can enable this option?
string s = 4;
In order to enable background compilation for C#, which checks you code while typing for many types of errors that are usually only reported when you build the project, you will have to install Service Pack 1 for Visual Studio 2008. If you use the offline MSDN, you will also want to install the updated MSDN Library for Visual Studio 2008 SP1, since there were framework changes from .NET 3.5 RTM to .NET 3.5 SP1 (such as the addition of Entity Framework).
Have you recently deinstalled ReSharper?
(see responses in the same link for other possibilities).
C# has never been as consistent about finding errors while i type as VB.net has. I always assumed it was just due to the freeform nature of the language, which would also explain why C++ never found errors either til build time.

Resources