Problem generating manifest.
"Problem generating manifest. Insufficient memory to continue the execution of the program."
I hate this error. Hate it with a passion. I work on a few Visual Studio projects of fairly large sizes. This error gets triggered from time to time when I perform a project build. It's hard to find a whole lot of information about this online. Solutions vary from resetting your Visual Studio project settings to disabling updates. I don't know if there's really any foolproof solution other than closing the project and re-opening it. Perhaps it's as simple as Visual Studio 2008 having a dreaded memory leak. Every developer faces a memory leak from time to time - certainly Microsoft is no different.
In my particular case, I did find a solution to the problem (which was caused by me).
Read more
Disable the ContextSwitchDeadlock MDA error in VS .NET 2008
I had written a handy little VB.NET app that copied a list of scripts to a set of servers. Well, sometimes these scripts take a little while to finish executing (adding indexes to large tables), so my tool would come back with the following error when I'd run it in debug mode.
"ContextSwitchDeadlock was detected Message: The CLR has been unable to transition from COM context 0x54a5d8 to COM context 0x54a748 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations."
Return to previous line of code in Visual Studio .NET 2008/2010
Here's a quick tip that probably won't change your development life, but will also probably come in handy when you're looking through a hierarchical chain of function calls in your code. I used to program in Visual Basic 6. I don't have a lot of fond memories of it, but there's one function that came in handy. That was the "Return to Previous Line" right-click function (I can't remember if that's exactly what it was called, but that was the idea). If I was debugging a function or sub-function that happened to call upon several other functions or subs from different modules and classes, the "Return to Previous Line" ability made it easier to find my way back to the original calling stack. Well...
Read more
When ReadXml returns blank rows (or no rows)
Here's one I ran into today. I'm programming along in VB.NET and I have an instance where I need to import data from an XML file into a DataSet (or in my case, a DataTable). I had (essentially) the following code.
Dim dt As New DataTable
dt.TableName = "newtable"
dt.ReadXML("c:\test.xml")
' Do stuff with dt.Rows(0)
Great. Well, this LOOKED like it would work. The solution would build without errors. When I ran the program in debug mode, however, I would get an exception error stating.
"There is no row at position 0"
Well WTF? What is this? After a bit of digging and poking around, I found that I had made a mistake by giving my DataTable variable a TableName value. This caused some clashing with the XML file that I was trying to import, as the table names did not match. This resulted in my imported DataTable having zero rows. The solution is to name your DataTable (if you need to) AFTER you import your XML file into the table. Such as...
Dim dt As New DataTable
dt.ReadXML("c:\test.xml")
dt.TableName = "newtable"
' Do stuff with dt.Rows(0)
AndAlso and OrElse - Difference in use and performance vs And/Or
In .NET languages (VB.NET, C#) we have a couple of short circuit operators available for use called AndAlso & OrElse. Not surprisingly, AndAlso is a short circuit variation of "And" and OrElse is a short circuit variation of "Or". That's great and all, but one might wonder why they would use these operators, and what benefits do they have over using the traditional "And" and "Or". Here's a couple of reasons. Read more
Setting SqlDataSource command timeout for ASP.NET
Here's a quick tip in regards to changing the command timeout for a SqlDataSource object in ASP.NET. Sometimes you'll want to increase the command timeout of a SqlDataSource object from 30 seconds (its default value) to something greater for resource intensive queries.
Read more
Check if a directory is empty in .NET 2008
For one reason or another, we may need to have our programs intelligently manage hard disk directory structure on the end user's PC. This would include such techniques as checking if a directory exists, creating a directory if it doesn't exist, clearing a directory, etc. This is actually a very easy process in .NET 2008 given the built in resources provided with Visual Studio. I'm going to be using VB.NET in my very simple example to check for the existence of a file directory.
Read more
Setup and Deployment Packages in Visual Studio 2008
Setup and deployment projects are frequently used by developers looking for a user friendly means to install their custom application on end users' computers. The result of creating a setup and deployment project is a portable and easy to use MSI installer package for your software. To create a bare minimum setup and deployment package for a Visual Studio application, follow these steps (written specifically for Visual Studio 2008).
1) Right click on your Visual Studio solution in the Solution Explorer panel in VS. Select "Add -> New Project..."
2) In the available project listing, select "Setup Project". Give it a name and location and click OK.
3) At this point, Visual Studio will display the file system on the target machine in your main development panel. Open the Application Folder here. Right click on the blank file system and select "Add -> Project Output..."
4) Select the project that you're creating this package for in the drop down listing. Then select the "Primary Output" option. Leave the rest of the settings as is and click OK.
5) You should see the primary output as well as any necessary dll files listed in the application folder in the development window. This is good. From here, right click on the setup and deployment project name in the solution explorer and select "Build".
6) Now you're done! The MSI and setup installation files for your custom application will be residing in the output folder that you specified when initially creating the package.
Intalling the AJAX toolkit for Visual Studio 2008
AJAX is a wonderful tool for dynamic web development. Samples of the tools included with the toolkit can be found here:
http://www.asp.net/ajax/ajaxcontroltoolkit/samples/
To install the latest edition of the AJAX toolkit for Visual Studio (in this case, Visual Studio 2008). Take the following steps.
1) Download the toolkit at http://www.asp.net/ajaxlibrary/download.ashx
2) Extract the .ZIP file downloaded anywhere on your hard drive.
3) Open Microsoft Visual Studio 2008. Right click on an empty space in the toolkit window on the left side of the screen. Select "Add Tab".
4) Give the tab a name. Right click under the named tab and select "Choose Items...". Once the .COM object window appears, click the "Browse" button.
5) Navigate to the folder where you extracted the AJAX toolkit .ZIP file. Select the AjaxControlToolkit.dll file there. Click OK to add the toolkit - and you're done!
Add or edit SQL 2008 DSN connections in VB.NET
Some programs created in Visual Studio 2008 require a SQL Server 2008 DSN connection to do various things like access databases, run Crystal Reports, etc. When deploying a program that needs a particular SQL 2008 DSN, it's a general pain to have to manually create a new SQL Native Client 10.0 DSN on every computer that the program is deployed too. Wouldn't you want to detect the presence of the needed SQL DSN (which we'll call SQLDSN), create it if it doesn't exist, and update it to include the needed server and database name if it does? This can be done using API calls. The first thing that you need to do is include the following line of code in the module, class, or form that will be adding or editing your DSN connection.
Private Declare Function SQLConfigDataSource Lib "ODBCCP32.DLL" (ByVal hwndParent As Integer, ByVal fRequest As Integer, ByVal lpszDriver As String, ByVal lpszAttributes As String) As Integer
This essentially includes an entry point to the SQLConfigDataSource function in ODBCCP32.DLL. Go to the MSDN definition of SQLConfigDataSource for more information about this function. Now - I have utilized this function first by creating my DSN attributes as follows.
Dim attr As String = "SERVER=" & server & Chr(0) & "DSN=SQLDSN" & Chr(0) & "DESCRIPTION=SQL 2008 DSN" & Chr(0) & "DATABASE=" & database & Chr(0)
Then I call the SQLConfigDataSource function with the following syntax to add the DSN.
SQLConfigDataSource(0, 4, "SQL Server Native Client 10.0", attr)
And with the following syntax to edit the DSN.
SQLConfigDataSource(0, 5, "SQL Server Native Client 10.0", attr)
The second parameter indicates what type of datasource the connection is (user or system), and also the action being taken (add, edit, or remove). Adding or editing a SQL Server 2008 DSN is as simple as this in VB.NET.