dynamically loading an assembly from a service (windows DRM)
WMPTalk.com Forum Index WMPTalk.com
Discuss Windows Media Player
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web wmptalk.com
dynamically loading an assembly from a service (windows DRM)

 
Post new topic   Reply to topic    WMPTalk.com Forum Index -> DRM
Author Message
Ollie Riches
Guest





Posted: Thu Oct 06, 2005 8:30 pm    Post subject: dynamically loading an assembly from a service (windows DRM) Reply with quote

I am trying to dynamically load an assembly that has a reference to
'Interop.WMEncoderLib.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.WMEncoderLib, 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.LoadFrom(assemblyName);
IIngestor ingestor = (IIngestor)loadedAssembly.CreateInstance(classType,
true, BindingFlags.Default, null, args, null, null);
if(ingestor == null)
throw new System.ArgumentException("Failed to create ingestor
invalid assembly or class name, assembly = '" + assemblyName + "', class
name ='" + classType + "'.");
return ingestor;
}

Can anyone help me out here

Cheers

Ollie Riches

Back to top
Ollie Riches
Guest





Posted: Thu Oct 06, 2005 8:30 pm    Post subject: Re: dynamically loading an assembly from a service (windows Reply with quote

Good Idea :) and probably will work, but doesn't explain why the assembly
isn't loading

Ollie

"Robert Jordan" <robertj@gmx.net> wrote in message
news:di3m6e$eo5$02$3@news.t-online.com...
Quote:
Ollie,

I am trying to dynamically load an assembly that has a reference to
'Interop.WMEncoderLib.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
Back to top
Robert Jordan
Guest





Posted: Thu Oct 06, 2005 8:30 pm    Post subject: Re: dynamically loading an assembly from a service (windows Reply with quote

Ollie,

Quote:
I am trying to dynamically load an assembly that has a reference to
'Interop.WMEncoderLib.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

Back to top
Ollie Riches
Guest





Posted: Thu Oct 06, 2005 8:30 pm    Post subject: Re: dynamically loading an assembly from a service (windows Reply with quote

found this and will have a look at it tomorrow:

http://blogs.msdn.com/suzcook/archive/2003/05/29/57120.aspx

Ollie

"Ollie Riches" <ollie.riches@phoneanalyser.net> wrote in message
news:u2HQyTqyFHA.2312@TK2MSFTNGP14.phx.gbl...
Quote:
Good Idea :) and probably will work, but doesn't explain why the assembly
isn't loading

Ollie

"Robert Jordan" <robertj@gmx.net> wrote in message
news:di3m6e$eo5$02$3@news.t-online.com...
Ollie,

I am trying to dynamically load an assembly that has a reference to
'Interop.WMEncoderLib.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

Back to top
Ollie Riches
Guest





Posted: Thu Oct 06, 2005 8:30 pm    Post subject: Re: dynamically loading an assembly from a service (windows Reply with quote

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/microsoft.public.dotnet.framework/browse_frm/thread/59fc2f276501e0e0/2bac04b9a4d3128d?lnk=st&q=Interop+assembly.load+failed+dependencies&rnum=1&hl=en#2bac04b9a4d3128d

Ollie

"Ollie Riches" <ollie.riches@phoneanalyser.net> wrote in message
news:%23zUcueqyFHA.4032@TK2MSFTNGP15.phx.gbl...
Quote:
found this and will have a look at it tomorrow:

http://blogs.msdn.com/suzcook/archive/2003/05/29/57120.aspx

Ollie

"Ollie Riches" <ollie.riches@phoneanalyser.net> wrote in message
news:u2HQyTqyFHA.2312@TK2MSFTNGP14.phx.gbl...
Good Idea :) and probably will work, but doesn't explain why the assembly
isn't loading

Ollie

"Robert Jordan" <robertj@gmx.net> wrote in message
news:di3m6e$eo5$02$3@news.t-online.com...
Ollie,

I am trying to dynamically load an assembly that has a reference to
'Interop.WMEncoderLib.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



Back to top
Ollie Riches
Guest





Posted: Fri Oct 07, 2005 4:30 pm    Post subject: Re: dynamically loading an assembly from a service (windows Reply with quote

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 AppendPrivatePath on
the current app domain but still it fails

Ollie

"Ollie Riches" <ollie.riches@phoneanalyser.net> wrote in message
news:%23%23%23x3iqyFHA.1252@TK2MSFTNGP09.phx.gbl...
Quote:
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/microsoft.public.dotnet.framework/browse_frm/thread/59fc2f276501e0e0/2bac04b9a4d3128d?lnk=st&q=Interop+assembly.load+failed+dependencies&rnum=1&hl=en#2bac04b9a4d3128d

Ollie

"Ollie Riches" <ollie.riches@phoneanalyser.net> wrote in message
news:%23zUcueqyFHA.4032@TK2MSFTNGP15.phx.gbl...
found this and will have a look at it tomorrow:

http://blogs.msdn.com/suzcook/archive/2003/05/29/57120.aspx

Ollie

"Ollie Riches" <ollie.riches@phoneanalyser.net> wrote in message
news:u2HQyTqyFHA.2312@TK2MSFTNGP14.phx.gbl...
Good Idea :) and probably will work, but doesn't explain why the
assembly isn't loading

Ollie

"Robert Jordan" <robertj@gmx.net> wrote in message
news:di3m6e$eo5$02$3@news.t-online.com...
Ollie,

I am trying to dynamically load an assembly that has a reference to
'Interop.WMEncoderLib.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





Back to top
Robert Jordan
Guest





Posted: Fri Oct 07, 2005 4:30 pm    Post subject: Re: dynamically loading an assembly from a service (windows Reply with quote

Hi Ollie,

Quote:
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 AppendPrivatePath on
the current app domain but still it fails

Are you still using Assembly.LoadFrom? 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.WMEncoderLib", but take a look at "gacutil -l"
output for the full name.

Rob
Back to top
Ollie Riches
Guest





Posted: Fri Oct 07, 2005 4:30 pm    Post subject: Re: dynamically loading an assembly from a service (windows Reply with quote

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" <robertj@gmx.net> wrote in message
news:di5ri8$p3d$03$1@news.t-online.com...
Quote:
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 AppendPrivatePath on
the current app domain but still it fails

Are you still using Assembly.LoadFrom? 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.WMEncoderLib", but take a look at "gacutil -l"
output for the full name.

Rob
Back to top
 
Post new topic   Reply to topic    WMPTalk.com Forum Index -> DRM All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



Microsoft Office Forum New Topics
Powered by phpBB