473,378 Members | 1,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,378 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 5202
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: 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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.