Hi everyone,
I have an app that uses some DLL's that are shared across couple applications. There are reasons existing that prevent me from putting them in to the GAC.
Each of these app's at some point in time loads a DLL dynamically in this fashion:
System.Reflection.Assembly assembly = null;
assembly = System.Reflection.Assembly.LoadFrom(_assemblyPath) ;
return assembly.CreateInstance(_typeName, false, System.Reflection.BindingFlags.Default, null, args, null, null);
_assemblyPath - DB driven that has a value for path. Now, if I have a path like this "C:\Mypath\My.dll" everything works fine. If I only have "My.dll" i get an error message saying the My.dll or one of its dependencies cannot be found. The exe and My.dll reside in the same folder and by default it should load when _assemblyPath = My.dll.
Any idea why its not working.
thanks a lot in advance. 7 1715
Try ".\\" + _assemblyPath;
"RSS" <q> wrote in message news:%2******************@TK2MSFTNGP04.phx.gbl...
Hi everyone,
I have an app that uses some DLL's that are shared across couple applications. There are reasons existing that prevent me from putting them in to the GAC.
Each of these app's at some point in time loads a DLL dynamically in this fashion:
System.Reflection.Assembly assembly = null;
assembly = System.Reflection.Assembly.LoadFrom(_assemblyPath) ;
return assembly.CreateInstance(_typeName, false, System.Reflection.BindingFlags.Default, null, args, null, null);
_assemblyPath - DB driven that has a value for path. Now, if I have a path like this "C:\Mypath\My.dll" everything works fine. If I only have "My.dll" i get an error message saying the My.dll or one of its dependencies cannot be found. The exe and My.dll reside in the same folder and by default it should load when _assemblyPath = My.dll.
Any idea why its not working.
thanks a lot in advance.
Just a stab in the dark... when you start the application, what is the
"Start in" current directory?
If you're running from a CMD command line, do you switch directories to
C:\Mypath and then run the app, or run it from wherever the current
directory is?
If you're running it from a desktop shortcut, what is your "Start in"
path set to?
I would assume that Assembly.LoadFrom would attempt to load from the
current directory if no path is specified, which may not be the same as
the directory where the executing assembly resides.
If you always want the latter behaviour, have you tried getting the
location of the running assembly using
string exePath = Assembly.GetExecutingAssembly().Location;
and then building the DLL name like this:
string dllPath = Path.Combine(Path.Combine(Path.GetPathRoot(exePath ),
Path.GetDirectoryName(exePath)), "My.dll");
?
Please post the exact exception message.
Willy.
"RSS" <q> wrote in message news:%2******************@TK2MSFTNGP04.phx.gbl...
Hi everyone,
I have an app that uses some DLL's that are shared across couple applications. There are reasons existing that prevent me from putting them in to the GAC.
Each of these app's at some point in time loads a DLL dynamically in this fashion:
System.Reflection.Assembly assembly = null;
assembly = System.Reflection.Assembly.LoadFrom(_assemblyPath) ;
return assembly.CreateInstance(_typeName, false, System.Reflection.BindingFlags.Default, null, args, null, null);
_assemblyPath - DB driven that has a value for path. Now, if I have a path like this "C:\Mypath\My.dll" everything works fine. If I only have "My.dll" i get an error message saying the My.dll or one of its dependencies cannot be found. The exe and My.dll reside in the same folder and by default it should load when _assemblyPath = My.dll.
Any idea why its not working.
thanks a lot in advance.
An unexpected exception was handled while processing job requests.
System.IO.FileNotFoundException: File or assembly name My.Core.dll, or one of its dependencies, was not found.
File name: "My.Core.dll"
at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Boolean isStringized, Evidence assemblySecurity, Boolean throwOnFileNotFound, Assembly locationHint, StackCrawlMark& stackMark)
at System.Reflection.Assembly.InternalLoad(AssemblyNa me assemblyRef, Boolean stringized, Evidence assemblySecurity, StackCrawlMark& stackMark)
at System.Reflection.Assembly.LoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm)
at System.Activator.CreateInstanceFrom(String assemblyFile, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo)
at My.Core.Typing.TypeDef.Instance(IDataReader dr)
at My.Core.Typing.Type.CacheType(String typeName)
at My.Core.Typing.Type.GetById(String typeName, Int32 typeId)
at My.Core.Activities.ActivityType.GetById(Int32 id)
at My.Core.Activities.Activity.List(IDbConnection connection)
at My.Scheduling.SchedulingServer.Version2Processing( )
at My.Scheduling.SchedulingServer.ProcessingLoop(Obje ct stateInfo)
=== Pre-bind state information ===
LOG: Where-ref bind. Location = C:\WINDOWS\system32\My.Core.dll
LOG: Appbase = c:\program files\Mine\scheduleingsetup\
LOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).
===
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/WINDOWS/system32/My.Core.dll.
"Willy Denoyette [MVP]" <wi*************@telenet.be> wrote in message news:OH**************@TK2MSFTNGP05.phx.gbl...
Please post the exact exception message.
Willy.
"RSS" <q> wrote in message news:%2******************@TK2MSFTNGP04.phx.gbl...
Hi everyone,
I have an app that uses some DLL's that are shared across couple applications. There are reasons existing that prevent me from putting them in to the GAC.
Each of these app's at some point in time loads a DLL dynamically in this fashion:
System.Reflection.Assembly assembly = null;
assembly = System.Reflection.Assembly.LoadFrom(_assemblyPath) ;
return assembly.CreateInstance(_typeName, false, System.Reflection.BindingFlags.Default, null, args, null, null);
_assemblyPath - DB driven that has a value for path. Now, if I have a path like this "C:\Mypath\My.dll" everything works fine. If I only have "My.dll" i get an error message saying the My.dll or one of its dependencies cannot be found. The exe and My.dll reside in the same folder and by default it should load when _assemblyPath = My.dll.
Any idea why its not working.
thanks a lot in advance.
RSS wrote: An unexpected exception was handled while processing job requests.
(...)
It is looking for the file in C:\windows\system32. Is your program a
windows service?
You might try the trick with Assembly.GetExecutingAssembly().Location
posted above.
Yes it is a windows service
".neter" <gw*****@poczta.onet.pl> wrote in message
news:e2**********@news.onet.pl... RSS wrote: An unexpected exception was handled while processing job requests. (...)
It is looking for the file in C:\windows\system32. Is your program a windows service? You might try the trick with Assembly.GetExecutingAssembly().Location posted above.
hi,
the "best" solution (only my opinion)
1) keep the interfaces of your libs compatible => signatures of public
props+methods
(the best is only 1 version of your lib in gac + publisher policy)
2) deploy your libs in the GAC, but only with publisher policies!
this will redirect your "old" clients to the new versions of your libs
loading manualy your libs may not be good for the code maintenance of
your libs ...
adrian This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Ron Vecchi |
last post by:
I am using the FlashShockWave COM object.
in the form design mode I specified the Flash Movie .SWF local path. and it
loads correctly.
My problem is that if I make changes to the swf file it...
|
by: TIM T |
last post by:
I want to load a user control from a dll dynamically to my main form.
I have been reading about using reflection. I got this to work with
the methods from my other classes in the dll but I am not...
|
by: Boni |
last post by:
Dear Sirs,
If I dynamically load assembly into the memory by Load(byte) how long do I
have to preserve the array valid? Can it be destructed just after the load
call?
Thanks in advance,
Boni
|
by: Marcel Balcarek |
last post by:
I create a user control dynamically:
Dim newCriteriaControl As CriteriaTextBoxUserControl =
CType(Me._page.LoadControl("CriteriaTextBoxUserControl.ascx"),
CriteriaTextBoxUserControl)
...
|
by: Nancy Sui |
last post by:
I am trying to dynamically load a dll which specifies different rules
for evalution with the following code.
DataRow dr = ds.Tables.Rows;
string fileName = Convert.ToString(dr);
assemblyInstance...
|
by: Reza Nabi |
last post by:
Bakground: I have a webform (LoadCtl.aspx) which loads the user control to a
placeholder dynamically based on the ctlName querystring passed in the URL.
Webform (LoadCtl.aspx) also passes a...
|
by: hitendra15 |
last post by:
Hi
I have created web user control which has Repeater control and
Linkbutton in ItemTemplate of repeater control, following is the code
for this control
On first load it runs fine but when...
|
by: netasp |
last post by:
hi all,
how can I populate one aspx form when page is loading based on page ID? for
example:
loading page A (to search for VB code) would display labels and texboxes,
dropdown lists all related...
|
by: chandu |
last post by:
hello ,
i want to load and execute an existing dll in a applicaiton dynamically with
out giving references etc...
need to create separate appdomain or in same appdomain can i load and
execute...
|
by: Nick |
last post by:
I have two navigation user controls and based on a query string will load one
or the other.
On the page that will load the user control I cannot do the following
Dim uc As FlashNavigation (The...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
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,...
|
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...
|
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,...
| |