Posts Tagged Visual Studio 2010

An invalid VARIANT was detected during a conversion from an unmanaged VARIANT to a managed object – C#

I have got this exception after I fixed this error, please check this post and read the following…!

Error Message:

“An invalid VARIANT was detected during a conversion from an unmanaged VARIANT to a managed object. Passing invalid VARIANTs to the CLR can cause unexpected exceptions, corruption or data loss.”

Fix:
Just go to the Debug menu in Visual studio and select Exceptions

Click and expand the Manage Debugging Assistants

Find the Invalid Variant node and uncheck the Thrown check box.

Click Ok and run the application, That’s all! Happy Programming..! If you want to read more about this issue, just read this post! 🙂

References:

http://www.dotnetspider.com/forum/299944-System.outofmemoryexception.aspx

http://blogs.msdn.com/b/yangxind/archive/2006/03/21/556837.aspx

Advertisement

, , , , , , , , , ,

2 Comments

The CLR has been unable to transition from COM context 0xXXXXXXX to COM context 0xYYYYYYY for 60 seconds – C#

Few months ago, I was developing a small windows application which gathers data from Active Directory(AD) and dumping into a SQL database table. There were around 18 to 20,000 records involved in the process. After developing and testing components with few data, everything was okay but when I run the application I got following error message:

“The CLR has been unable to transition from COM context 0x2297ce0 to COM context 0x2297f30 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.”

I didn’t want to spend too much time with this error and I have found the quick fix from this site, if you want to know more about this please read there. 😉

Here are the steps to fix this error;

Step 1: Go to Debug –> Exceptions  in Visual Studio 2010 (I was using 2010)

Step 2: Click on  Managed Debug Assistants

Step 3:  Un-check the ContextSwitchDeadlock and click OK

That’s all,  the problem was fixed but I have got an other error, please see the same kind of solution here.

References:

http://dotnetdud.blogspot.ca/2009/01/clr-has-been-unable-to-transition-from.html

, , , , , , ,

2 Comments

The type or namespace name ‘SharePoint’ does not exist in the namespace ‘Microsoft’ (are you missing an assembly reference?) – SharePoint 2010 Client Object Model dlls

When I started using the Client Object model (Client OM) in SharePoint 2010, I have got this simple error and I just want to share with you in this blog. Following was my develpment environment.

  • Windows 7, 64 bit
  • Console Application Visual Studio 2010
  • Added Client Object Model references (Microsoft.SharePoint.Client.dll & Microsoft.SharePoint.Client.Runtime.dll) to the solution

After setting up all the above, I was trying to add the client reference to the code ‘using Microsoft.SharePoint.Client;‘and then I have got the following error and warnings 🙂

The text format of error is:

"The type or namespace name 'SharePoint' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)"

It’s an obvious error message and the reason of this error is:

SharePoint 2010 does not support .Net 4.0 in default and Visual Studio 2010 default framework is .Net 4.0.

Here are the simple steps to fix this:

Step 1: Right click on the project –> Properties

Step 2: Change the Target framework –> .Net Framework 3.5

Step 3: Warning message will be popping up, click Yes.

That’s all. Happy Coding..!

Please Note: If you use Windows Application then you will be getting an other error message! 😦 To solve this issue just click here.

, , , , , , , , , ,

1 Comment

Getting started with Silverlight – Visual Studio 2010

Actually this is  my first Silverlight application development, I didn’t get any chance to work with Silverlight in a real time project, so I just wanted to try an application with Silverlight in Visual Studio 2010. It is pretty simple like windows application. 🙂

This is my environment: Visual Studio 2010, Silverlight 4 developer edition and Windows 7.

When I tried to create an application, I have got few version conflict problems and I resolved them. You can see in my previous post if you need. Okay.. we will see the steps.

Step 1: Open the Visual Studio and click New Project

Step 2: Choose the programming language and select Silverlight node in the left pane.

Step 3:  Select the Silverlight application on the middle pane and enter the application name on the Textbox then click ok. 

Step 4: You will be getting the following screen.

Please Note: If you want to enable the WCF RIA Services to access the external data using this application then click the check box. I don’t want to do any, so I just click ok.

Step 5: Here is our solution explorer. If you want to learn about the files and other stuffs just click here and learn more.

Step 6: Just click on the Toolbox on the left side vertical tab (If not shown just click View –> Toolbox OR Ctrl+W, X) and drag and drop the button.

Step 7: Modify the button properties (You can either modify in the property tab on the right side (as usual we do) OR you can modify in the XAML pane).

I have given the button Name=”buttonClick”, Content=”Click”, Height=”50″ and Width=”100″

Step 8: Like button add TextBox and a Label as well. So our design will be displaying like this.

and the XAML:

<Grid x:Name="LayoutRoot" Background="White">
 <Button Content="Click" Height="50" HorizontalAlignment="Left" Margin="152,133,0,0" Name="buttonClick" VerticalAlignment="Top" Width="100" />
 <TextBox Height="25" HorizontalAlignment="Left" Margin="85,70,0,0" Name="textBoxEnter" VerticalAlignment="Top" Width="230" />
 <TextBlock Height="25" HorizontalAlignment="Left" Margin="85,101,0,0" Name="textBlockDisplay" Text="" VerticalAlignment="Top" Width="230" />
</Grid>

Step 9: Double click on the Button to create the click event (You can do this on the right side event tab also) and then write the c# code to getting the string form TextBox and displaying on the Label.

private void buttonClick_Click(object sender, RoutedEventArgs e)
 {
 textBlockDisplay.Text = "Hello " + textBoxEnter.Text;
 buttonClick.Content = "Clicked";
 }

Step 10: That’s all guys, just click the run button (F5) to see our 1st Silverlight application. 🙂

Happy Silverlighing..! We will see the database access later! 🙂

Thanks R./

, , , , , , , ,

1 Comment