473,405 Members | 2,421 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

CreateInstanceAndUnwrap

Max
I'm using CreateInstanceAndUnwrap as follows:

object myinstance = myAppDomain.CreateInstanceAndUnwrap("LibraryFile",
"LibraryFileNamespace.LibraryFileClass", true, 0, null, null, null, null, null);

to get an instance of the LibraryFileClass so I can call a function in this class, and I

get the following compile error:

System.Runtime.Serialization.SerializationExceptio n: The type LibraryFileNamespace.LibraryFileClass in Assembly LibraryFile,
Version=1.0.2117.26436, Culture=neutral, PublicKeyToken=null is not marked as serializable.

Can someone explain to me why am I getting this error and how I can fix it?

Nov 17 '05 #1
2 8613
Max,

When you create an instance in another app domain, you have to either
serialize the object when you use it in your current app domain, or have it
derive from MarshalByRefObject so that you can access it through a proxy.

If you want the instance of the object to live in the new application
domain, then you have to have that object derive from MarshalByRefObject.
This means that all calls to the object will be forwarded through a proxy to
that app domain. Otherwise, it has to be serializable, and all calls will
be on a copy created in the local domain.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Max" <ma******@yahoo.com> wrote in message
news:e2*************@TK2MSFTNGP09.phx.gbl...
I'm using CreateInstanceAndUnwrap as follows:

object myinstance = myAppDomain.CreateInstanceAndUnwrap("LibraryFile",
"LibraryFileNamespace.LibraryFileClass", true, 0, null, null, null, null,
null);

to get an instance of the LibraryFileClass so I can call a function in
this class, and I

get the following compile error:

System.Runtime.Serialization.SerializationExceptio n: The type
LibraryFileNamespace.LibraryFileClass in Assembly LibraryFile,
Version=1.0.2117.26436, Culture=neutral, PublicKeyToken=null is not marked
as serializable.

Can someone explain to me why am I getting this error and how I can fix
it?

Nov 17 '05 #2
Max
Got it, thanks.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:Oy**************@TK2MSFTNGP15.phx.gbl...
Max,

When you create an instance in another app domain, you have to either
serialize the object when you use it in your current app domain, or have it
derive from MarshalByRefObject so that you can access it through a proxy.

If you want the instance of the object to live in the new application
domain, then you have to have that object derive from MarshalByRefObject.
This means that all calls to the object will be forwarded through a proxy to
that app domain. Otherwise, it has to be serializable, and all calls will
be on a copy created in the local domain.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Max" <ma******@yahoo.com> wrote in message
news:e2*************@TK2MSFTNGP09.phx.gbl...
I'm using CreateInstanceAndUnwrap as follows:

object myinstance = myAppDomain.CreateInstanceAndUnwrap("LibraryFile",
"LibraryFileNamespace.LibraryFileClass", true, 0, null, null, null, null,
null);

to get an instance of the LibraryFileClass so I can call a function in
this class, and I

get the following compile error:

System.Runtime.Serialization.SerializationExceptio n: The type
LibraryFileNamespace.LibraryFileClass in Assembly LibraryFile,
Version=1.0.2117.26436, Culture=neutral, PublicKeyToken=null is not marked
as serializable.

Can someone explain to me why am I getting this error and how I can fix
it?


Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Eli Abitbol | last post by:
Hi All I am using a few Microsoft application blocks in our winforms applications I am having problem with the Microsoft.ApplicationBlocks.ExceptionManagement components The samples for...
1
by: Mrudul Sadanandan | last post by:
H I am trying to create object in the current app domain using CreateInstanceAndUnwrap. It is throwing the exception. Any ide ...
6
by: Pablo | last post by:
Hi, I'm creating an AppDomain and creating an instance of a class. This works fine unless I use caching, which I need to use. The exception that I get is of type "System.IO.FileLoadException"...
1
by: Niklas Magnusson | last post by:
During deployment for a project i want to perform a number of tasks automatically. for example update a database. Theese tasks needs configuration settings from the .config file that are included...
3
by: karunakar | last post by:
Hi All Here iam getting this Error "Specified cast is not valid." My Project has Onc solution diffrent class libarary In that solution DALfactory solution iam getting this error I was calling...
2
by: brianbender | last post by:
I am trying to load and unload assemblies dynamically and call methods and properties when loaded into an Appdomain I can load assemblies all day in the current AppDomain without references and...
15
by: Untitled | last post by:
I have an ASP .NET web application that displays information. At the same time, i have a web service that collects information from various client applications. This data needs to be processed...
1
by: Frank Uray | last post by:
Hi all I still have some problems with AppDomain ... :-(( I am loading a dll by using AppDomain, AssemblyName and Assembly. This works fine. My dll implements a Interface. Now I would like to...
11
by: sunil | last post by:
Dear All, I have created a .Net service in 2.0 and running it on a machine that has a Quad Processor. It is failing with the following error. "Error 1053: The service did not respond to the start...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.