473,786 Members | 2,344 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

AppDomain and Reflection

I have the following code that creates a new appDomain and loads an exe
using reflection. The problem I have is the exe file I pass in is still
locked by the application. I have showcopyfiles = "true" and specified the
locations for the appDomain to use. The shadowfiles and the original file is
locked when I execute the command tmpAssm = .Load(strApplic ationName). Now
if I have shadowcopyfiles on, why would setting the assembly to the file
lock it? Any help is appreciated.

John

Private tmpDomain As AppDomain

Public Function LoadProgram(ByV al strApplicationN ame As String, ByVal
strApplicationE ntryPoint As String) As Form

Dim tmpAppDomain As New AppDomainSetup

Dim tmpAssm As Assembly

Dim strName() As String

Dim strVersion As String

tmpAppDomain.Ap plicationBase = "d:\wzprogr ams"

tmpAppDomain.Sh adowCopyFiles = "true"

tmpAppDomain.Sh adowCopyDirecto ries = "d:\wzprogr ams"

tmpAppDomain.Pr ivateBinPath = "d:\wzprogr ams"

'set the cache path for shadow files

tmpAppDomain.Ca chePath = "d:\wzprograms\ tmp"

tmpDomain = AppDomain.Creat eDomain("Temp", AppDomain.Curre ntDomain.Eviden ce,
tmpAppDomain)

With tmpDomain

'.ExecuteAssemb ly("D:\wzprogra ms\versioncheck .exe")

tmpAssm = .Load(strApplic ationName)

'.ExecuteAssemb ly(strApplicati onName)

End With

'Get the version of the program

strName = Split(tmpAssm.F ullName.ToStrin g, ",")

strVersion = strName(1)

'set up the form to display by calling the Entry Point for the program.

LoadProgram = tmpAssm.CreateI nstance(strAppl icationEntryPoi nt, True)

Dim extType As Type = tmpAssm.GetType (strApplication EntryPoint)

Dim extInfo As MethodInfo = extType.GetMeth od("SetProperti es")

If extInfo Is Nothing Then

MsgBox("This program cannot be run in the framework.", MsgBoxStyle.Cri tical,
"Invalid Framework Program")

Exit Function

End If

Dim myParamArray() As Object = {12345}

extInfo.Invoke( LoadProgram, myParamArray)

LoadProgram.Nam e = ("Test")

LoadProgram.Tex t = "VersionChe ck. " & strVersion

AppDomain.Unloa d(tmpDomain)

End Function

May 23 '06 #1
0 1203

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

Similar topics

7
1712
by: Dave L | last post by:
I am inquiring about the feasability of being able to determine when an object of a certain type is instantiated. I have a base type that I want to be able to determine when each instance is created in an assembly. Can this be done using Reflection or AppDomain? I'm trying to detect these instances automatically for some security settings. Any help would be greatly appreciated.
4
4206
by: stu_pb | last post by:
I am designing a plugin system for a window application using .NET(C# specifically). One of the requirements of the plugin system is to be able to dynamically load/unload plugins. My initial thought was to use System.Reflection.Assembly.Load to load the plugins dynamically. This worked great, but I was left with no way to dynamically unload the plugin. So now I come to creating a new AppDomain for the plugins to reside in, since the...
4
2880
by: Mark | last post by:
I wan't to be able to deserialize a class from an assembly that is not in the application domain. To do that I must have the Type from the Assembly. How do you get a Type from an assembly that is not in the manifest of the current AppDomain. I have tried different ways but get exceptions from all of them that say the: assembly or one of its dependancies could not be found. There must be missing something.
0
1189
by: kozen | last post by:
I want to pass a WinForm control from main appDomain A to another appDomain B. In appDomain B, i will create some WinForm controls and add them to the control's child controls list of main appDomain A . But i failed, please tell me why. thanks! code sample: // BOView will be created in appDomain B. // BOView receive aParCtrl from main appDomain A, then add some controls to
1
2400
by: Raveendra M | last post by:
Hi! I am working with ASP.NET application. In my page I am creating one Application Domain and in that domain I am calling my DLL. Using the methods of the dll. And unloading the Application Domain. Till this point it is working fine. My problem is, while web page is open, than I am modifying the dll, and rebuilding. Then it is giving error: "The file 'MyClass.dll' cannot be copied to the run directory. The process cannot access the...
1
2355
by: Charles Herring | last post by:
In my asp.net application I upload a video file and then need to get the duration and other properties. I get "Attempted to access an unloaded AppDomain" when I instanciate the Video object. I am impersonating Administrator. Here is the code: Dim v As Video = New Video(fname, True) intHeight = v.DefaultSize.Height
3
2391
by: hB | last post by:
Hi. Error = "The configuration system can only be set once. Configuration system is already set" Exception Details: System.InvalidOperationExcepti­on: The configuration system can only be set once. Configuration system is already set
3
22148
by: Frank Uray | last post by:
Hi all I have a problem with loading a assembly ... I am trying to do the following: - I have a directory with a dll (assembly) in it (not the currect dir.) - I am trying to load this assembly, run a method in it, and than close it. The question would be: How is the right way to do it ????
0
887
by: John Wright | last post by:
I have the following code that creates a new appDomain and loads an exe using reflection. The problem I have is the exe file I pass in is still locked by the application. I have showcopyfiles = "true" and specified the locations for the appDomain to use. The shadowfiles and the original file is locked when I execute the command tmpAssm = .Load(strApplicationName). Now if I have shadowcopyfiles on, why would setting the assembly to the...
0
10357
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10163
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9959
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7510
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6744
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5532
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4063
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3668
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.