473,387 Members | 1,585 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,387 software developers and data experts.

Need help: CreateInstanceFromAndUnwrap

I am trying to create and instantiate a class into a created domain, so that I can unload the domain and replace the class (assembly .dll) while the main application is running, but I can't get it to work for some reason.

Here is the code:

' Create an appdomain
Try
Dim setup As AppDomainSetup = New AppDomainSetup
setup.ApplicationBase = "C:\test"
setup.PrivateBinPath = AppDomain.CurrentDomain.BaseDirectory
setup.ApplicationName = "MyDomain"
appd = AppDomain.CreateDomain("Domain", Nothing, setup)
Catch ex As Exception
MsgBox("Can't create domain: " & ex.Message)
End Try

' Loads an class into the newly created appdomain
Try
Dim test As Object = appd.CreateInstanceFromAndUnwrap("smallclass.dll", "test.SmallClass")
Catch ex As Exception
MsgBox("Can't initiate the class: " & ex.Message)
End Try
The class I am trying to instantiate is in its own solution, and looks like:
Namespace test
Public Class SmallClass
Inherits MarshalByRefObject

Public Sub test()
MsgBox("Test in SmallClass")
End Sub

End Class
End Namespace

Creating the domain works, and the CreateInstanceFromAndUnwrap method finds the DLL, but it can't find the class according to the error message. I don't have any explicit namespace, and the class is called CAPfast, with the correct case. The class also have a public constructor without any arguments.

The error message is in swedish, but here is a translation: It was not possible to load the type test.SmallClass from the assembly SmallClass, Version=1.0.1395.24153, Culture=neutral, PublicKeyToken=null

Anyone have any idea why this isn't working?

Jul 21 '05 #1
0 1061

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

Similar topics

1
by: LilleSkutt | last post by:
I am trying to create and instantiate a class into a created domain, so that I can unload the domain and replace the class (assembly .dll) while the main application is running, but I can't get it to...
0
by: Serge calderara | last post by:
Hello I have an application which works with plug-ins components that I load using follwoing code AppDomain.CurrentDomain.AppendPrivatePath("." + Global.ENVIRONMENT_PATH.PLUGINS_FILE_PATH obj...
0
by: Francis Gingras | last post by:
Hi,I'm getting a "assembly or one of its dependancies could not be found" error when running the code below.The code works fine when called by a .NET program, but fails when called by an assembly...
0
by: LilleSkutt | last post by:
I am trying to create and instantiate a class into a created domain, so that I can unload the domain and replace the class (assembly .dll) while the main application is running, but I can't get it to...
15
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
8
by: skumar434 | last post by:
i need to store the data from a data base in to structure .............the problem is like this ....suppose there is a data base which stores the sequence no and item type etc ...but i need only...
0
by: U S Contractors Offering Service A Non-profit | last post by:
Brilliant technology helping those most in need Inbox Reply U S Contractors Offering Service A Non-profit show details 10:37 pm (1 hour ago) Brilliant technology helping those most in need ...
0
by: Michael | last post by:
Hi Everyone, I'm having a problem loadin a assembly into memory. Here is the code I'm trying to run(Its a C# convert from an article (Search Dynamically for Plug-ins): Dim domain As AppDomain =...
20
by: mike | last post by:
I help manage a large web site, one that has over 600 html pages... It's a reference site for ham radio folks and as an example, one page indexes over 1.8 gb of on-line PDF documents. The site...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.