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

Help please: 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("CAP Fast.dll", "CAPfast")
Catch ex As Exception
MsgBox("Can't initiate the class: " & ex.Message)
End Try

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.

Anyone have any idea why this isn't working?
Nov 22 '05 #1
1 5192
Can you include the text of the exception you are seeing?

One possibility is that a dependency required by the CAPfast class is missing, so the type cannot be loaded. If this is the
case, using the Fuslogvw.exe tool might help you figure out what's going wrong. If you're not familiar with this tool, it's part of
the .NET framework SDK. Launch fuslogvw.exe, check the "Log Failures" box, and run your code again. After it fails, go
back to fuslogvw.exe and click the Refresh button. If the problem is a missing dependency, you should see a log entry
describing the failure. Double click on the application name in the left-hand column to bring up a page with more details.

Thanks,
Grayson
--------------------
| >Thread-Topic: Help please: CreateInstanceFromAndUnwrap
| >thread-index: AcOchBg9QHfFmPGCSs+RDYErJBHKUw==
| >X-Tomcat-NG: microsoft.public.dotnet.general
| >From: "=?Utf-8?B?TGlsbGVTa3V0dA==?=" <an*******@discussions.microsoft.com>
| >Subject: Help please: CreateInstanceFromAndUnwrap
| >Date: Mon, 27 Oct 2003 04:16:05 -0800
| >Lines: 25
| >Message-ID: <DA**********************************@microsoft.co m>
| >MIME-Version: 1.0
| >Content-Type: text/plain;
| > charset="Utf-8"
| >Content-Transfer-Encoding: 7bit
| >X-Newsreader: Microsoft CDO for Windows 2000
| >Content-Class: urn:content-classes:message
| >Importance: normal
| >Priority: normal
| >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| >Newsgroups: microsoft.public.dotnet.general
| >NNTP-Posting-Host: TK2MSFTCMTY1 10.40.1.180
| >Path: cpmsftngxa06.phx.gbl!cpmsftngxa07.phx.gbl!cpmsftng xa10.phx.gbl
| >Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.general:113310
| >X-Tomcat-NG: microsoft.public.dotnet.general
| >
| >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("CAP Fast.dll", "CAPfast")

Catch ex As Exception

MsgBox("Can't initiate the class: " & ex.Message)

End Try

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.

Anyone have any idea why this isn't working?
| >
Nov 22 '05 #2

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: 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...
2
by: Serge calderara | last post by:
Dear all I am using the following code in my applciation AppDomain.CurrentDomain.AppendPrivatePath("\Plugins" objDomain = AppDomain.CurrentDomain.CreateInstanceFromAndUnwrap(Name + ".dll",...
7
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title>...
5
by: Craig Keightley | last post by:
Please help, i have attached my page which worksin IE but i cannnot get the drop down menu to fucntion in firefox. Any one have any ideas why? Many Thanks Craig ...
23
by: Jason | last post by:
Hi, I was wondering if any could point me to an example or give me ideas on how to dynamically create a form based on a database table? So, I would have a table designed to tell my application...
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...
4
by: Max | last post by:
Hi, I would like to be able to load an assembly file at runtime which will do some work. When the work is done I would like the main application to be informed so that the assembly can be...
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 =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.