Kai Huener
7/2/2004 8:12:00 AM
Hi Sunny,
Thank you again and again for helping me, but this time I could not score
with your tip. First I thought, to put the assembly to the GAC would solve
the problem, but the Exception was the same. I did the following:
1. I createt a key pair to get a strong name for the assembly
2. I added the attribute "[assembly:AssemblyKeyFileAttribute(keyFileName)]"
to the struct code
3. I added the assembly to the GAC by using the .NET Framework Configuration
Tool
4. (Here I was not realy sure!) I added a refference to the lokal
(ProjectFolder) stored assembly
I''m not sure, how to reference an assembly placed in the GAC, but I could
not find any other assembly as this one in my ProjectFolder.
Ok, this didn''t work, then I wanted to try your tip No. 2, but I could not
find any AppDomain-Object out of my AddIn-File. There I have only a
Microsoft.Office.Interop.Word.Application-Object, but there is no AppDomain
in view. Can you tell me, how to get it out of the OnConnection-Method of my
AddIn?
I hope not to bore you :-)
Thank you and Regards,
Kai
"Sunny" <sunnyask@icebergwireless.com> schrieb im Newsbeitrag
news:%23e8EZDtXEHA.2868@TK2MSFTNGP09.phx.gbl...
> Hi Kai,
>
> when the addin is loaded, it''s process folder is not the folder from
> which it is loaded, but the folder of the running process. So most
> probably the framework tries to find the assembly with the struct in
> some other folder and fails.
>
> I had this problems before, so 2 possible solutions:
> 1. Put it in the GAC
> 2. in your Connect method capture the AppDomain.AssemblyResolve event
> and try in the handler to load the assembly from the path you want.
>
>
> Hope that helps
> Sunny
>
>
> In article <eFREzWcXEHA.3188@TK2MSFTNGP09.phx.gbl>, mail@kaihuener.de
> says...
> > Thank you, this would explain why my AddIn does not do what I want, but
I''m
> > not shure, if this is realy the probelm, because in a console
application, I
> > can use my selfdefined struct out of the marshaled remoteObject. Perhaps
I
> > have to add some serialisation information, but i don''t know details.
> >
> > Regards,
> > Kai Huener
> >
> > "Richard Bell" <richardb@rogge.co.uk> schrieb im Newsbeitrag
> > news:%23C7xUDcXEHA.1764@TK2MSFTNGP10.phx.gbl...
> > > Might be related or not, but marshaling of arrays of user defined
structs
> > is
> > > not supported by Com interop.
> > >
> > > "Kai Huener" <mail@kaihuener.de> wrote in message
> > > news:ut88a2bXEHA.1684@tk2msftngp13.phx.gbl...
> > > > Hi Sunny,
> > > >
> > > > Yes, the assembly references all are correct, whenn I use the code
in a
> > > > console Application, there are no problems. Now I tried to wrap also
the
> > > > struct, like you described in the other post, but its realy ennoying
to
> > > > write extra code for things which normaly have to work. All would be
so
> > > > easy, if I could use the CodeElement or Solution Objects from .NET,
you
> > > > realy don''t know any way to serialize these COM-Objects?
> > > >
> > > > Thank you,
> > > > Kai Huener
> > > >
> > > >
> > > > "Sunny" <sunnyask@icebergwireless.com> schrieb im Newsbeitrag
> > > > news:%23cY1K0RXEHA.3596@tk2msftngp13.phx.gbl...
> > > > > Do you use tha same assembly referenced both from the server and
the
> > > > > client. Both programs need to reference and use the same assembly
in
> > > > > which your struct is defined.
> > > > >
> > > > > Sunny
> > > > >
> > > > >
> > > > > In article <bff5fc22.0406250157.7bae9e8f@posting.google.com>,
> > > > > mail@kaihuener.de says...
> > > > > > Hello,
> > > > > >
> > > > > > I want to use a self defined struct within a remoteObject in the
> > > > > > following way to send data from an AddIn in VisualStudio to an
AddIn
> > > > > > in MS Word:
> > > > > >
> > > > > > ...
> > > > > > public class Remote Object : MarshalByRefObject
> > > > > > {
> > > > > > ...
> > > > > > public ArrayList GetCodeElements()
> > > > > > {
> > > > > > ...
> > > > > > ArrayList retval = new ArrayList();
> > > > > > foreach(...)
> > > > > > {
> > > > > > StructElement strEl = new StructElement();
> > > > > > strEl.Name = "TestName";
> > > > > > retval.Add(strEl);
> > > > > > }
> > > > > > return retval;
> > > > > > }
> > > > > > ...
> > > > > > }
> > > > > >
> > > > > > [Serializable]
> > > > > > public struct StructElement
> > > > > > {
> > > > > > ...
> > > > > > private string name;
> > > > > >
> > > > > > public string Name
> > > > > > {
> > > > > > get { return this.name; }
> > > > > > set { this.name = value; }
> > > > > > }
> > > > > > ...
> > > > > > }
> > > > > >
> > > > > > When I try all this without the struct in the returning
ArrayList
> > only
> > > > > > by using a single string, it works, so I think the remote call
by
> > > > > > client is ok. Also there are no problems, when I use a
ConsoleApp as
> > > > > > Client and not the AddIn in Word. But when I call the relevant
> > > > > > function out of the Word AddIn, I get an "unmanaged exception"
with
> > > > > > the message "The XML-key ... StructElement is not assigned by an
> > > > > > assembly" (my own translation from german to english, sorry :-))
> > > > > >
> > > > > > Have you any idea, what I have to do to solve this problem?
> > > > > >
> > > > > > Kai Huener
> > > > > >
> > > >
> > > >
> > >
> > >
> >
> >
> >