This code works great in a windows application:
// Dynamically load the DLL
sDLLName = "..\\bin\\Test2.dll";
Assembly objAssembly = System.Reflection.Assembly.LoadFrom(sDLLName);
// Create an instance of the class
object testObject = objAssembly.CreateInstance("Test2.Test");
// Call the method "TestMessage" which has one argument
object[] object2 = new object[1];
object2[0] = 200;
MethodInfo Method = testObject.GetType().GetMethod("TestMessage");
object result = Method.Invoke(testObject, object2);
// This should return 300 and does
Console.WriteLine(result.ToString());
However, from a web service project, I can't seem to get this to work. It
can't find the DLL.
Questions:
* Does IIS sandbox the project and not allow external references?
* Is there a special way that IIS needs set up to allow this?
* I assume that IIS works with server paths, so maybe the path I have
specified above does not work. Should I be using a different path variable?
* Does IIS shadow the web service files to another location making this
approach impossible?
Any help is most appreciated!
Thanks!
Michael 3 1899
- asp.net doesn't sandbox by default (can change this in web.config)
- what happens if you change the code to?
sDLLName = "Test2.DLL";
Assembly.Load(sDLLName)
and place Test2.DLL in the bin directory of the web service
- asp.net does shadow copy DLLs but that shouldn't affect the path operations.
Niroo [MSFT]
"moflaherty" wrote: This code works great in a windows application:
// Dynamically load the DLL sDLLName = "..\\bin\\Test2.dll"; Assembly objAssembly = System.Reflection.Assembly.LoadFrom(sDLLName);
// Create an instance of the class object testObject = objAssembly.CreateInstance("Test2.Test");
// Call the method "TestMessage" which has one argument object[] object2 = new object[1]; object2[0] = 200;
MethodInfo Method = testObject.GetType().GetMethod("TestMessage"); object result = Method.Invoke(testObject, object2);
// This should return 300 and does Console.WriteLine(result.ToString());
However, from a web service project, I can't seem to get this to work. It can't find the DLL.
Questions:
* Does IIS sandbox the project and not allow external references? * Is there a special way that IIS needs set up to allow this? * I assume that IIS works with server paths, so maybe the path I have specified above does not work. Should I be using a different path variable? * Does IIS shadow the web service files to another location making this approach impossible?
Any help is most appreciated!
Thanks! Michael
Hi! The problem is that we use the same DLLs for other apps on the server.
For example, a windows service, desktop app, etc. It would be nice to have
the same DLL used in all cases and not 3 copies for each project.
Thanks!
Michael
"Niroo TP" wrote: - asp.net doesn't sandbox by default (can change this in web.config) - what happens if you change the code to? sDLLName = "Test2.DLL"; Assembly.Load(sDLLName)
and place Test2.DLL in the bin directory of the web service
- asp.net does shadow copy DLLs but that shouldn't affect the path operations.
Niroo [MSFT]
"moflaherty" wrote:
This code works great in a windows application:
// Dynamically load the DLL sDLLName = "..\\bin\\Test2.dll"; Assembly objAssembly = System.Reflection.Assembly.LoadFrom(sDLLName);
// Create an instance of the class object testObject = objAssembly.CreateInstance("Test2.Test");
// Call the method "TestMessage" which has one argument object[] object2 = new object[1]; object2[0] = 200;
MethodInfo Method = testObject.GetType().GetMethod("TestMessage"); object result = Method.Invoke(testObject, object2);
// This should return 300 and does Console.WriteLine(result.ToString());
However, from a web service project, I can't seem to get this to work. It can't find the DLL.
Questions:
* Does IIS sandbox the project and not allow external references? * Is there a special way that IIS needs set up to allow this? * I assume that IIS works with server paths, so maybe the path I have specified above does not work. Should I be using a different path variable? * Does IIS shadow the web service files to another location making this approach impossible?
Any help is most appreciated!
Thanks! Michael
As I mentioned before, you should always use Assembly.Load() instead of
Assembly.LoadFrom() when you are loading the assembly to use its
functionality.
If you want to have 1 copy of the files in a single location, you have a
few options:
1) Put the files in the Global Assembly Cache http://msdn.microsoft.com/library/de...emblycache.asp
2) Use the codebase element of assemblyBinding in your config file: http://msdn.microsoft.com/library/de...rfcodebase.asp
3) Use the probing element of assemblyBinding in your config file: http://msdn.microsoft.com/library/de...grfprobing.asp
For a great resource on understanding Fusion (the .NET assembly loader),
do this workshop: http://www.grimes.demon.co.uk/workshops/fusionWS.htm
Joshua Flanagan http://flimflan.com/blog
moflaherty wrote: Hi! The problem is that we use the same DLLs for other apps on the server. For example, a windows service, desktop app, etc. It would be nice to have the same DLL used in all cases and not 3 copies for each project.
Thanks! Michael
"Niroo TP" wrote:
- asp.net doesn't sandbox by default (can change this in web.config) - what happens if you change the code to? sDLLName = "Test2.DLL"; Assembly.Load(sDLLName)
and place Test2.DLL in the bin directory of the web service
- asp.net does shadow copy DLLs but that shouldn't affect the path operations.
Niroo [MSFT]
"moflaherty" wrote:
This code works great in a windows application:
// Dynamically load the DLL sDLLName = "..\\bin\\Test2.dll"; Assembly objAssembly = System.Reflection.Assembly.LoadFrom(sDLLName);
// Create an instance of the class object testObject = objAssembly.CreateInstance("Test2.Test");
// Call the method "TestMessage" which has one argument object[] object2 = new object[1]; object2[0] = 200;
MethodInfo Method = testObject.GetType().GetMethod("TestMessage"); object result = Method.Invoke(testObject, object2);
// This should return 300 and does Console.WriteLine(result.ToString());
However, from a web service project, I can't seem to get this to work. It can't find the DLL.
Questions:
* Does IIS sandbox the project and not allow external references? * Is there a special way that IIS needs set up to allow this? * I assume that IIS works with server paths, so maybe the path I have specified above does not work. Should I be using a different path variable? * Does IIS shadow the web service files to another location making this approach impossible?
Any help is most appreciated!
Thanks! Michael This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Rodrigo Meneses |
last post by:
Hello.
Does somebody know how to invoke a web service using reflection in c#?
Thanks in advance
-Rodrigo Meneses Pinillos
|
by: david.kao |
last post by:
Hi All:
I am releasing a Win Client .Net program with Web Service in strong name
though a shared network driver, and on each user’s desktop I am giving a
machine level full trust with my win...
|
by: moflaherty |
last post by:
This code works great in a windows application:
// Dynamically load the DLL
sDLLName = "..\\bin\\Test2.dll";
Assembly objAssembly = System.Reflection.Assembly.LoadFrom(sDLLName);
// Create an...
|
by: Steve Amey |
last post by:
Hi all
I am using reflection to read the values of properties from a class. The
class is returned from a Web Service so I have to access the class using
FieldInfo (Using VS 2003 which converts...
|
by: JT |
last post by:
Hi,
I am having trouble finding information about GUIDs and strong-names
and don't really know what I need. If that's too ambiguous, please
tell me where to look for info on these.
Here's...
|
by: George |
last post by:
Hello,
I am building an assembly that connects to a third party application via
http. I need create a http message that I post to the third party
application. The message is very complicated...
|
by: John Bode |
last post by:
I need a way to fake reflection in C++ code that makes as few
assumptions about the data types involved as possible. I suspect
there is no good answer for what I need to do, but I'll present the...
|
by: =?Utf-8?B?UVNJRGV2ZWxvcGVy?= |
last post by:
I have a C# logging assembly with a static constructor and methods that is
called from another C# Assembly that is used as a COM interface for a VB6
Application. Ideally I need to build a file...
|
by: =?Utf-8?B?c2lwcHl1Y29ubg==?= |
last post by:
Hi
I am slightly familiar with reflection but have never done the following
I know how to find a class and call but I haven't done the following
The Method return a List of Another Class
And...
|
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...
|
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...
|
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: 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...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
| |