473,554 Members | 2,928 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

dynamically loading an assembly from a service (windows DRM)

I am trying to dynamically load an assembly that has a reference to
'Interop.WMEnco derLib.dll' which is a PIA to the windows media player DRM
components. When I run the code from a console application it works
perfectly fine, but when the assembly containing the reference is load from
a windows service an exception is thrown with the following message:

"File or assembly name Interop.WMEncod erLib, or one of its dependencies, was
not found."

Now I am guessing this is because the windows service runs under the
location of 'windows root\system32' not where there service execute is
installed. The assemblies I am loading at runtime resides in a sub directory
(with all the dll's referenced by the assembly) and are designed as a
plugable architecture that returns an interface to the caller.

public static IIngestor CreateInstance( string assemblyName, string
classType, object[] args)
{
Assembly loadedAssembly = Assembly.LoadFr om(assemblyName );
IIngestor ingestor = (IIngestor)load edAssembly.Crea teInstance(clas sType,
true, BindingFlags.De fault, null, args, null, null);
if(ingestor == null)
throw new System.Argument Exception("Fail ed to create ingestor
invalid assembly or class name, assembly = '" + assemblyName + "', class
name ='" + classType + "'.");
return ingestor;
}

Can anyone help me out here

Cheers

Ollie Riches
Nov 17 '05 #1
7 3032
Ollie,
I am trying to dynamically load an assembly that has a reference to
'Interop.WMEnco derLib.dll' which is a PIA to the windows media player DRM
components. When I run the code from a console application it works
perfectly fine, but when the assembly containing the reference is load from
a windows service an exception is thrown with the following message:


If that assembly is a PIA, why don't you install it into the GAC?

Rob
Nov 17 '05 #2
Good Idea :) and probably will work, but doesn't explain why the assembly
isn't loading

Ollie

"Robert Jordan" <ro*****@gmx.ne t> wrote in message
news:di******** *****@news.t-online.com...
Ollie,
I am trying to dynamically load an assembly that has a reference to
'Interop.WMEnco derLib.dll' which is a PIA to the windows media player DRM
components. When I run the code from a console application it works
perfectly fine, but when the assembly containing the reference is load
from a windows service an exception is thrown with the following message:


If that assembly is a PIA, why don't you install it into the GAC?

Rob

Nov 17 '05 #3
found this and will have a look at it tomorrow:

http://blogs.msdn.com/suzcook/archiv.../29/57120.aspx

Ollie

"Ollie Riches" <ol**********@p honeanalyser.ne t> wrote in message
news:u2******** ******@TK2MSFTN GP14.phx.gbl...
Good Idea :) and probably will work, but doesn't explain why the assembly
isn't loading

Ollie

"Robert Jordan" <ro*****@gmx.ne t> wrote in message
news:di******** *****@news.t-online.com...
Ollie,
I am trying to dynamically load an assembly that has a reference to
'Interop.WMEnco derLib.dll' which is a PIA to the windows media player
DRM components. When I run the code from a console application it works
perfectly fine, but when the assembly containing the reference is load
from a windows service an exception is thrown with the following
message:


If that assembly is a PIA, why don't you install it into the GAC?

Rob


Nov 17 '05 #4
I think I will try using the AssemblyResolve event on the current appDomain
to see if that can help resolve the location of the interop assembly.

found an interresting google at:

http://groups.google.com/group/micro...ac04b9a4d3128d

Ollie

"Ollie Riches" <ol**********@p honeanalyser.ne t> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
found this and will have a look at it tomorrow:

http://blogs.msdn.com/suzcook/archiv.../29/57120.aspx

Ollie

"Ollie Riches" <ol**********@p honeanalyser.ne t> wrote in message
news:u2******** ******@TK2MSFTN GP14.phx.gbl...
Good Idea :) and probably will work, but doesn't explain why the assembly
isn't loading

Ollie

"Robert Jordan" <ro*****@gmx.ne t> wrote in message
news:di******** *****@news.t-online.com...
Ollie,

I am trying to dynamically load an assembly that has a reference to
'Interop.WMEnco derLib.dll' which is a PIA to the windows media player
DRM components. When I run the code from a console application it works
perfectly fine, but when the assembly containing the reference is load
from a windows service an exception is thrown with the following
message:

If that assembly is a PIA, why don't you install it into the GAC?

Rob



Nov 17 '05 #5
Still failing, but if I place the assemblies in the same directory as the
service binary then it loads the assemblies perfrectly fine.

I have tried using the AssemblyResolve event and the AppendPrivatePa th on
the current app domain but still it fails

Ollie

"Ollie Riches" <ol**********@p honeanalyser.ne t> wrote in message
news:%2******** ************@TK 2MSFTNGP09.phx. gbl...
I think I will try using the AssemblyResolve event on the current appDomain
to see if that can help resolve the location of the interop assembly.

found an interresting google at:

http://groups.google.com/group/micro...ac04b9a4d3128d

Ollie

"Ollie Riches" <ol**********@p honeanalyser.ne t> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
found this and will have a look at it tomorrow:

http://blogs.msdn.com/suzcook/archiv.../29/57120.aspx

Ollie

"Ollie Riches" <ol**********@p honeanalyser.ne t> wrote in message
news:u2******** ******@TK2MSFTN GP14.phx.gbl...
Good Idea :) and probably will work, but doesn't explain why the
assembly isn't loading

Ollie

"Robert Jordan" <ro*****@gmx.ne t> wrote in message
news:di******** *****@news.t-online.com...
Ollie,

> I am trying to dynamically load an assembly that has a reference to
> 'Interop.WMEnco derLib.dll' which is a PIA to the windows media player
> DRM components. When I run the code from a console application it
> works perfectly fine, but when the assembly containing the reference
> is load from a windows service an exception is thrown with the
> following message:

If that assembly is a PIA, why don't you install it into the GAC?

Rob



Nov 17 '05 #6
Hi Ollie,
Still failing, but if I place the assemblies in the same directory as the
service binary then it loads the assemblies perfrectly fine.

I have tried using the AssemblyResolve event and the AppendPrivatePa th on
the current app domain but still it fails


Are you still using Assembly.LoadFr om? This method is
actually loading the assembly either from the full path
you specified or relatively to the app's current directory.

Try Assembly.Load with the strong name of the PIA.

For the first, the strong name can be as simple as
"Interop.WMEnco derLib", but take a look at "gacutil -l"
output for the full name.

Rob
Nov 17 '05 #7
Cheers for the help Robert, I have been using LoadFrom with fully qualified
path with no success.

I will have to resort to either putting the plugin dll's in the same
directory as the windows service or as you suggested registering the PIA's
in the GAC. But for now i have it working and will address this problem
again next week.

Cheers for the help

Ollie

"Robert Jordan" <ro*****@gmx.ne t> wrote in message
news:di******** *****@news.t-online.com...
Hi Ollie,
Still failing, but if I place the assemblies in the same directory as the
service binary then it loads the assemblies perfrectly fine.

I have tried using the AssemblyResolve event and the AppendPrivatePa th on
the current app domain but still it fails


Are you still using Assembly.LoadFr om? This method is
actually loading the assembly either from the full path
you specified or relatively to the app's current directory.

Try Assembly.Load with the strong name of the PIA.

For the first, the strong name can be as simple as
"Interop.WMEnco derLib", but take a look at "gacutil -l"
output for the full name.

Rob

Nov 17 '05 #8

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

Similar topics

4
11668
by: David Elliott | last post by:
I am trying to load an assembly and execute a method from a class. I have listed 3 parts to the code. 1) The Driver to load and execute 2) The Interface 3) The assembly I have a valid referece to the assembly. When I try to create an instance of the class, it returns a null value. Any help would be appreciated.
2
328
by: KK | last post by:
Hi all Can anybody help me what's going wrong here and how to correct it. Code is as follows.... System::Object * GetObjectFromAssembly() { Assembly * pMyAssembly = Assembly::Load("MyAssembly"); Type * pMyType = pMyAssembly->GetType("MyNameSpace.MyClass"); System::Object * pRet = pMyType->CreateInstance(); pMyAssembly = 0;
1
3996
by: Vivek | last post by:
HI Everyone, I am trying to dynamically load a custom deployed assembly from the GAC of a remote machine so that i could call its method from my code using reflection. Can anyone tell me how do i do this? Any help would be appreciated. Thanks Vivek
1
5000
by: Benjamin | last post by:
Hi, I'm currently writing a Web Services that interacts with a database. To allow me to use not just one database provider (for example, I could use MS Access, SQL Server or MySQL), the Web Service dynamically loads up an assembly that implements an Interface I called IDatabase. To load the assembly and create an object, I wrote this...
1
1268
by: M. Fitzgerald | last post by:
Our migration from ASP to ASP.NET will be a slow one. In themeantime, I have constructed a .NET assembly and registered itas a COM object for use in out classic ASP pages. One of thethings this particular assembly does is use Reflection todynamically load another assembly (based of course onuser-provided parameters). The original error is in...
2
985
by: Pradeep | last post by:
Hi, We devised smart client technology in our application. We used web service to download a assembly which is there in system32 folder of web server using "System.Reflection" MyAssembly = .LoadFrom("AsmSACM.dll") Application has been successfully deployed in windows 2000
6
6870
by: Dan Dorey | last post by:
I actually have two questions here, but I'll start by giving an outline of what I'm trying to do. I'm building an app with a simple plugin architecture (all in the same app domain). I have each plugin in a separate sub-dir inside a "Plugins" directory. Each plugin consists of at least two DLLs (a controller and a driver). However, most...
2
3095
by: Smithers | last post by:
Using 3.5, I am stuck in attempting to: 1. Dynamically load an assembly 2. Instantiate a class from that assembly (the client code is in a different namespace than the namespace of the dynamically loaded assembly) so far so good (per my code below)... but here is where I'm getting hung up: 3. Call methods of that type (see comments in my...
7
10047
by: chage | last post by:
Hi, I have been searching around to try adding reference assembly to another assembly during runtime, programatically. Is this possible in .Net? The reason for this is because i am having trouble using a library that creates an instance of a Type that i specified, and it failed the locate the Type during runtime, if i do not reference it...
0
7600
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7521
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8042
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...
1
7563
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6145
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5436
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...
0
5155
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...
0
3548
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2020
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

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.