That sounds great, but I can't get it to work. I changed the Activator call
to be:
Object o = Activator.CreateInstance
( "Archiver, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null",
"MSR.LST.ArchiveService.Archiver",
new Object[]{new UrlAttribute("tcp://localhost:8082")} );
I got the assembly name programmatically, so it should be correct (is there
another way to get that?). The exception thrown was:
FileNotFoundException: Message "File or assembly name Archiver, or one of
its dependencies, was not found." The call stack indicated was (with some
chopped off the bottom):
mscorlib.dll!System.Reflection.Assembly.InternalLoad(System.Reflection.AssemblyName
assemblyRef = {System.Reflection.AssemblyName}, bool stringized = true,
System.Security.Policy.Evidence assemblySecurity = <undefined value>,
System.Threading.StackCrawlMark stackMark = LookForMyCaller) Line 1136 + 0x19
bytes C#
mscorlib.dll!System.Reflection.Assembly.InternalLoad(string assemblyString
= "Archiver, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null",
System.Security.Policy.Evidence assemblySecurity = <undefined value>,
System.Threading.StackCrawlMark stackMark = LookForMyCaller) Line 1101 + 0x13
bytes C#
mscorlib.dll!System.Activator.CreateInstance(string assemblyName =
"Archiver, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null", string
typeName = "MSR.LST.ArchiveService.Archiver", bool ignoreCase = false,
System.Reflection.BindingFlags bindingAttr = 532, System.Reflection.Binder
binder = <undefined value>, System.Object[] args = <undefined value>,
System.Globalization.CultureInfo culture = <undefined value>, System.Object[]
activationAttributes = {Length=1}, System.Security.Policy.Evidence
securityInfo = <undefined value>, System.Threading.StackCrawlMark stackMark =
LookForMyCaller) Line 250 + 0xd bytes C#
mscorlib.dll!System.Activator.CreateInstance(string assemblyName =
"Archiver, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null", string
typeName = "MSR.LST.ArchiveService.Archiver", System.Object[]
activationAttributes = {Length=1}) Line 158 + 0x20 bytes C#
> ArchiverDotDispose.exe!ArchiverDotDispose.Form1.SetupArchiver() Line 446 + 0x4c bytes C#
Any suggestions?
Thanks,
-pb
> > I believe you have to supply the fully assembly name (with version, culture,
> > etc.) when calling Activator.CreateInstance().
[quoted text clipped - 44 lines]
> >>Thanks,
> >>-pb
Ken Kolda - 27 Sep 2004 22:43 GMT
Now that I look at the error I realize I gave you irrelevant advice. If you
want to use CAOs without the implementation on the client, the only way I
know of to do that is using the Factory model (i.e. have an SAO which
returns CAO instances from its methods). The problem with
Activator.CreateInstance() is that it the overload you're using:
Activator.CreateInstance(assemblyName, typeName, attributes)
is equivalent to calling this sequence of code:
Assembly a = Assembly.Load(assemblyName);
Type t = a.GetType(typeName);
Activator.CreateInstance(t, attributes);
This is clearly not what you wanted because you don't want the client to
load the type.
Ken
> That sounds great, but I can't get it to work. I changed the Activator call
> to be:
[quoted text clipped - 8 lines]
> its dependencies, was not found." The call stack indicated was (with some
> chopped off the bottom):
mscorlib.dll!System.Reflection.Assembly.InternalLoad(System.Reflection.Assem
blyName
> assemblyRef = {System.Reflection.AssemblyName}, bool stringized = true,
> System.Security.Policy.Evidence assemblySecurity = <undefined value>,
> System.Threading.StackCrawlMark stackMark = LookForMyCaller) Line 1136 + 0x19
> bytes C#
> mscorlib.dll!System.Reflection.Assembly.InternalLoad(string
assemblyString
> = "Archiver, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null",
> System.Security.Policy.Evidence assemblySecurity = <undefined value>,
[quoted text clipped - 14 lines]
> activationAttributes = {Length=1}) Line 158 + 0x20 bytes C#
> > ArchiverDotDispose.exe!ArchiverDotDispose.Form1.SetupArchiver() Line 446
+ 0x4c bytes C#
> Any suggestions?
>
[quoted text clipped - 50 lines]
> > >>Thanks,
> > >>-pb
Patrick Bristow - 28 Sep 2004 00:05 GMT
Ahh... how bizarre... you see, I just rewrote the object so that it uses an
interface published in a seperate assembly. I've been doing work on this
project for most of a month now just using a CAO and "new'ing" the instances.
By call stack I had verified that it was creating the objects on the server,
so I knew it was all working fine. But since I want to do it "right", I
really can't do it w/o a seperate SAO for a class factory? Wow... that's a
pain.
Ok, thanks so much.
-pb
> Now that I look at the error I realize I gave you irrelevant advice. If you
> want to use CAOs without the implementation on the client, the only way I
[quoted text clipped - 120 lines]
> > > >>Thanks,
> > > >>-pb
Robert Jordan - 28 Sep 2004 00:27 GMT
> Ahh... how bizarre... you see, I just rewrote the object so that it uses an
> interface published in a seperate assembly. I've been doing work on this
[quoted text clipped - 3 lines]
> really can't do it w/o a seperate SAO for a class factory? Wow... that's a
> pain.
You can generate class stubs (empty implementations) for
your CAOs with soapsuds.exe (SDK tool). The stubs allow
you "new'ing" the CAOs w/out deploying the full implementation
on the client.
However, I find SAO + class factory a much cleaner approach.
bye
Rob
> Ok, thanks so much.
> -pb
[quoted text clipped - 148 lines]
>>>>>>Thanks,
>>>>>>-pb