.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Post New Web Links

SerializationException is catched when using native dll in ASP.NET

Posted By:      Posted Date: September 23, 2010    Points: 0   Category :.NET Framework
Hi expert,

There is a managed c++ project, which is used to wrapper one Native c++ project. And then I will use it in ASP.Net.

When I call the method of one ref class of  this managed C++ project, I will get the followed log in call stack.
  msvcm90d.dll!<CrtImplementationDetails>::GetDefaultDomain() Line 390 + 0x8 bytes C++
  msvcm90d.dll!<CrtImplementationDetails>::DoCallBackInDefaultDomain(int* function = 0x10F92EA0, bool cookie = false) Line 442 + 0x6 bytes C++
  msvcm90d.dll!<CrtImplementationDetails>::DefaultDomain::Initialize() Line 284 C++
  msvcm90d.dll!<CrtImplementationDetails>::LanguageSupport::InitializeDefaultAppDomain() Line 519 C++


And when call "MANAGED_ASSERT(pDomain->IsDefaultAppDomain(), "Expecting default appdomain")", I will get one error:
"An exception of type 'System.Runtime.Serialization.SerializationException' occurred in mscorlib.dll but was not handled in user code"

I try to research something for this kind of issue, and find there are some thoughts that this issue is caused by the difference of AppDomain used by ASP and the native dll--Asp.net runs on non-default Appdomain, but the native dll runs on defautl Appdomain
In order to verify it, I create a little example to test, and at an AppDomain check co

View Complete Post

More Related Resource Links

CLR Inside Out: Best Practices For Managed And Native Code Interoperability


There are many factors to consider when building your app with both managed and native code. Find out how to employ interop and how to choose the interop that's right for you.

Jesse Kaplan

MSDN Magazine January 2009

GUI Library: Bring the Simplicity of Windows Forms to Native Apps


In this article, author John Torjo presents a guide to his C++ GUI library called eGUI++ and explains how it makes user interface programming easier.

John Torjo

MSDN Magazine June 2008

WinUnit: Simplified Unit Testing for Native C++ Applications


Maria Blees introduces WinUnit, a handy new unit testing tool for native C++ projects.

Maria Blees

MSDN Magazine February 2008

XmlLite: A Small And Fast XML Parser For Native C++


XmlLite provides a high-performance, low-overhead XML reader and writer geared for applications written in native C++. Learn more here.

Kenny Kerr

MSDN Magazine April 2007

Netting C++: Mapping Native C++ to the Common Type System


This month Stanley Lippman begins translating the Text Query Language Query class hierarchy from C++ to the .NET Common Type System.

Stanley B. Lippman

MSDN Magazine February 2007

Wrappers: Use Our ManWrap Library to Get the Best of .NET in Native C++ Code


By now you're probably used to reaching into the .NET Framework using Managed Extensions with your C++ code. But what do you do if you have legacy apps that use older versions of the compiler, or if you want to avoid some of the CLR requirements? Well, you can wrap Framework classes in a native way so you can use them in any C++/MFC app without /clr. Paul DiLascia shows you how.

Paul DiLascia

MSDN Magazine April 2005

XML in Yukon: New Version Showcases Native XML Type and Advanced Data Handling


The next version of Microsoft SQL Server, code-named "Yukon," represents quite a few steps forward in the evolution of XML integration. Yukon supports native storage of XML data using the XML data type, which makes it possible to run native queries on XML data using the emerging industry standard XQuery language. Data integrity of the XML data type can be enforced through schema validation and XML-based check constraints, and special indexes can be defined that help speed up queries. In addition, Yukon has the built-in ability to expose its data through Web services. This article discusses these and other XML features of Yukon.

Bob Beauchemin

MSDN Magazine February 2004

'mscorlib.dll' targets a different processor/.net calling a native dll

I  have a vb.net that calls a dll in native cpp.  Works fine in 32bit.  Now I want to upgrade to 64 bit.  I've done this before and it worked but now get a runtime error.  Compiles ok but with the error noted in the subject line. Also, when I try to debug, the ide tells me that it can't debug managed and native.  Yes it can, I just forgot how. platform is win7, intel 64 bit.  any suggestion to the forum/whitepaper or ideas are greatly appreciated. Thanks in advance! Robert.

AppDomain.Unload effects Unable to evaluate expression because the code is optimized or a native fra

Hello, I create a custom AppDomain.Create().  I registered the Unhandled Exception Event from my custom AppDomain. In the Unhandled Exception Event i try to Unload my AppDomain with AppDomain.Unload. But this effects a "Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack." Have anyone a idea what i can do against this behaviour. greetints

SerializationException using JSON Serializer

I'm getting a SerializationException with the following message when I deserialize a simple object serialized with JSON: Expecting element 'root' from namespace ''.. Encountered 'None'  with name '', namespace ''. Any ideas what's wrong?  Here is the code: namespace     JSONSerialization {     class Program { [   DataContract ]     public class Info { [   DataMember ]     public string version; }     static void Main( string [] args) {     Info apiInfo = new Info () {version = "1.0" };     MemoryStream stream1 = new MemoryStream ();     DataContractJsonSerializer ser = new DataContractJsonSerializer ( typeof ( Info )); ser.WriteObject(stream1, apiInfo   );     Info proxyReceived = ( Info )ser.ReadObject(stream1);     Console .WriteLine( string .Format( "{0}: {1}" , "API version" , proxyReceived.version)); } } }

SerializationException with CallContext

Hi I have a Visual Studio Add-In written in C# that uses the CallContext object.  When Visual Studio starts a build of the opened solution, I get the following error: Unknown build error, 'Type is not resolved for member 'Codice.CM.Common.CmCallContext,commontypes, Version=, Culture=neutral, PublicKeyToken=a107c9c6e34c8876'.' The error occurs because Visual Studio launches the build process in a new AppDomain, and it needs to deserialize our CallContext (CmCallContext) object and it can't be load the commontypes.dll library because it is in other AppDomain (or dll is not registered in the GAC). So I have found some solutions but any is good for me: 1. Register commontypes.dll assembly in the GAC 2. Ensure that CallContext is clean before Visual Studio make anything (setting it to null). We tried to implement this solution but is quite difficult for us, because it implies clean callcontext after a server call, and we have a lot of server calls scattered throughout the code. We could centralize these calls, but it is very difficult because that would have a lot of delegates, and it would be very difficult to maintain. Somebody knows other workaround for this issue? Thanks in advanced,  Daniel

Install SQL Server2005 Error:[Native Client]Encryption not supported on the client

Product: Microsoft SQL Server 2005 -- Error 29515. SQL Server Setup could not connect to the database service for server configuration. The error was: [Microsoft][SQL Native Client]Encryption not supported on the client. Refer to server error logs and setup logs for more information. For details on how to view setup logs, see "How to View Setup Log Files" in SQL Server Books Online.

Error: A native exception has occurred in my_file.exe

Hello everyone,   This error is occurring with me when I am working with SSCE in my pocket PC. Can anyone tell me why?   Thanks!

ArgumentOutOfRangeException Crossed native/managed boundary

When run my application i got this error at the starting. ArgumentOutOfRangeException Crossed native/managed boundary Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index How solve this. This Exception coming when i access the following private Collection m_coll; Public Collection coll {   set{m_coll=value;}   get{return m_coll;} } I have initialized the coll in constructor. In 2010 its working fine. Thanks,

When trying to install SQL 2008 Reporting 'Install the native mode default configuration' is greye

Whilst troubleshooting an earlier issue with SQL 2008 R1 I needed to install SQL without reporting, I then went through the SQL add feature to add Reporting once SQL was working.  The issue I am getting is that the option I need for SCOM R2 'Install the native mode default configuration' is greyed out and the only choice I have is 'Install, but do not configure the report server' which apparently happens when you don't install reporting at the same time as installing the SQL database engine.  In order for SCOM reporting to install I need manually configure SQL reporting to how it is configured when you install in native mode.  Can anyone help with a document on how to configure this manually ? thanks

Native exception 0xc0000005 when using SQLCE 3.0/3.1 and .NET CF 2.0?!

Greetings, I have written a very basic C# console test app to check the performance and reliability of SQLCE on Windows CE 5.0 (source code below). Running this on different Windows CE 5.0 devices, I always get a 0xc0000005 native exception error when reaching 25592 inserts. It doesn't matter whether the database is empty or not when the test is run, it always fails at that exact number of inserts. Given that I would expect a managed application not to be able to generate native exceptions anyway, and can't really see any reason why it would in this case, I'm at a bit of a loss as to what's going wrong... Any ideas? Using: VS2005 w/ SP1 Windows CE 5.0 (on custom SH4 platform and HTC WM5 smartphone) .NET CF 2.0 w/ SP1 and post SP1 patch SQLCE 3.0.3600.0 TIA PS. The same code (with some SQLCE 3.0 specific bits removed - version and result set for checking table existence) works perfectly under .NET CF 1.0 and SQLCE 2.0). Source code: using System.Data; using System.Data.SqlServerCe; namespace TestDB {     class Program     {         static void Main(string[] args)         {             SqlCeConnection sqlConnection = new SqlCeConnection();             SqlCeCommand sqlCommand = sqlConnection.CreateCommand();             SqlCeResultSet sqlResult;             string strDatabase = "\\TestDB.sdf";             string strTable = "TestTable";        
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend