[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

mail

6/17/2004 10:24:00 AM

Hallo,

I have a problem by using .NET Remote, allthough it is quit good
documented. I have 2 AddIns, one in MS Word 2003 and the other in
VisualStudio and I'd like to create an remoteObjekt in VisualStudio
from Word to use it in Word - so it is a simple Remote Call over an
application domain.

I tried this:

Here is the code of my RemoteObject:

using System;
using EnvDTE;

public class SmartSpecRemoteObject : MarshalByRefObject
{
private Solution currentSolution;

public SmartSpecRemoteObject()
{
}

public Solution GetSolution()
{
return this.currentSolution;
}

#region Properties

public Solution CurrentSolution
{
get { return this.currentSolution; }
set { this.currentSolution = value; }
}

#endregion
}

--------------------------------------------------------

relevant Code of VS AddIn:

HttpServerChannel channel = new HttpServerChannel(8080);
ChannelServices.RegisterChannel(channel);

RemotingConfiguration.RegisterWellKnownServiceType(typeof(SmartSpecRemoteObject),
"remoteObjectUri", WellKnownObjectMode.SingleCall);

SmartSpecRemoteObject remObj = new SmartSpecRemoteObject();

remObj.CurrentSolution = this.applicationObject.Solution;
ObjRef ref1 = RemotingServices.Marshal(remObj, "remoteObjectUri");

--------------------------------------------------------

and the relevant code of th CLient Word AddIn:

HttpClientChannel channel = new HttpClientChannel();
ChannelServices.RegisterChannel(channel);

SmartSpecRemoteObject remoteObject =
(SmartSpecRemoteObject)Activator.GetObject(typeof(SmartSpecRemoteObject),
"http://localhost:8080/remoteObjectUri");

My Problem is, the property I create in VS is not sent to Word. Also
it could be, that in Word there is a new Object without the Property
created. I don't know, but there is no remoteObject.CurrentSollution
in Word, and to have this was my aim to to all this remote stuff!

Perhaps someone of you has an idea to help me to get a curent
VisaulStudio Solution to Word,

Thank you,
Kai
4 Answers

Sunny

6/17/2004 2:25:00 PM

0

You are declaring yout object as SingleCall, which means that on every
invocation a new object is created. And ... no one has set the property.

You do not need RegisterWellKnown..., Marshal is what you need. Now in
your code you are exposing 2 objects on the same Uri, and I can not tell
you which one will take precedence.

Your VS AddIn code should be:

HttpServerChannel channel = new HttpServerChannel(8080);
ChannelServices.RegisterChannel(channel);

SmartSpecRemoteObject remObj = new SmartSpecRemoteObject();

remObj.CurrentSolution = this.applicationObject.Solution;
ObjRef ref1 = RemotingServices.Marshal(remObj, "remoteObjectUri", typeof
(SmartSpecRemoteObject));

Sunny


In article <bff5fc22.0406170223.19e62624@posting.google.com>,
mail@kaihuener.de says...
> Hallo,
>
> I have a problem by using .NET Remote, allthough it is quit good
> documented. I have 2 AddIns, one in MS Word 2003 and the other in
> VisualStudio and I''d like to create an remoteObjekt in VisualStudio
> from Word to use it in Word - so it is a simple Remote Call over an
> application domain.
>
> I tried this:
>
> Here is the code of my RemoteObject:
>
> using System;
> using EnvDTE;
>
> public class SmartSpecRemoteObject : MarshalByRefObject
> {
> private Solution currentSolution;
>
> public SmartSpecRemoteObject()
> {
> }
>
> public Solution GetSolution()
> {
> return this.currentSolution;
> }
>
> #region Properties
>
> public Solution CurrentSolution
> {
> get { return this.currentSolution; }
> set { this.currentSolution = value; }
> }
>
> #endregion
> }
>
> --------------------------------------------------------
>
> relevant Code of VS AddIn:
>
> HttpServerChannel channel = new HttpServerChannel(8080);
> ChannelServices.RegisterChannel(channel);
>
> RemotingConfiguration.RegisterWellKnownServiceType(typeof(SmartSpecRemoteObject),
> "remoteObjectUri", WellKnownObjectMode.SingleCall);
>
> SmartSpecRemoteObject remObj = new SmartSpecRemoteObject();
>
> remObj.CurrentSolution = this.applicationObject.Solution;
> ObjRef ref1 = RemotingServices.Marshal(remObj, "remoteObjectUri");
>
> --------------------------------------------------------
>
> and the relevant code of th CLient Word AddIn:
>
> HttpClientChannel channel = new HttpClientChannel();
> ChannelServices.RegisterChannel(channel);
>
> SmartSpecRemoteObject remoteObject =
> (SmartSpecRemoteObject)Activator.GetObject(typeof(SmartSpecRemoteObject),
> "http://localhost:8080/remoteObjectUri");
>
> My Problem is, the property I create in VS is not sent to Word. Also
> it could be, that in Word there is a new Object without the Property
> created. I don''t know, but there is no remoteObject.CurrentSollution
> in Word, and to have this was my aim to to all this remote stuff!
>
> Perhaps someone of you has an idea to help me to get a curent
> VisaulStudio Solution to Word,
>
> Thank you,
> Kai
>

Kai Huener

6/21/2004 7:42:00 AM

0

Hi,

First I want to say thank you for your Help, I could solve my Problem
with aour Post. But now, I got another Problem: In my first post, aou
can see what I want to do, and it nearly works, but I can not use all
Properties of my remoting object. When I call
remObj.CurrentSolution.FullName for example, there is no Problem, but
when I try to use remObj.CurrentSolution.Projects.Count, it does not
work and I get an exception, wich says I could not use EnvDTE.Projects,
but I included this assembly everywhere.

You also got an answer to this porblem? Would be great,

Kai


*** Sent via Devdex http://www.... ***
Don''t just participate in USENET...get rewarded for it!

Sunny

6/21/2004 3:02:00 PM

0

The better approach is to wrap somehow EnvDTE object, and to expose only
the wrapper and only the methods/properties you need. EnvDTE is a COM
object, and there a lot of implication to remote it.

Something like this:

class MyWrapper : MBR
{
.......
public int ProjectsCount
{
get {return EnvDTE.Projects.Count;}
}

//other methods and properties
}


Sunny


In article <#pS0KN2VEHA.3420@TK2MSFTNGP12.phx.gbl>, mail@kaihuener.de
says...
> Hi,
>
> First I want to say thank you for your Help, I could solve my Problem
> with aour Post. But now, I got another Problem: In my first post, aou
> can see what I want to do, and it nearly works, but I can not use all
> Properties of my remoting object. When I call
> remObj.CurrentSolution.FullName for example, there is no Problem, but
> when I try to use remObj.CurrentSolution.Projects.Count, it does not
> work and I get an exception, wich says I could not use EnvDTE.Projects,
> but I included this assembly everywhere.
>
> You also got an answer to this porblem? Would be great,
>
> Kai
>
>
> *** Sent via Devdex http://www.... ***
> Don''t just participate in USENET...get rewarded for it!
>

Kai Huener

6/21/2004 3:14:00 PM

0

Hi Sunny,

Ok, I nearly understand, but I already tried to add another Property to my
RemoteObject like

public ArrayList Projects

{

get

{

foreach(Project project in this.currentSolution)

{

this.projects.Add(project);

}

return this.projects;

}

}

And this does not work to when I tried to get access to the Project objects
of the arrayList. Can you tell me, where I have to put the wrapper? To the
Server, or to the remoteObjectClass?

Thank you,

Kai





"Kai Huener" <mail@kaihuener.de> schrieb im Newsbeitrag
news:bff5fc22.0406170223.19e62624@posting.google.com...
> Hallo,
>
> I have a problem by using .NET Remote, allthough it is quit good
> documented. I have 2 AddIns, one in MS Word 2003 and the other in
> VisualStudio and I''d like to create an remoteObjekt in VisualStudio
> from Word to use it in Word - so it is a simple Remote Call over an
> application domain.
>
> I tried this:
>
> Here is the code of my RemoteObject:
>
> using System;
> using EnvDTE;
>
> public class SmartSpecRemoteObject : MarshalByRefObject
> {
> private Solution currentSolution;
>
> public SmartSpecRemoteObject()
> {
> }
>
> public Solution GetSolution()
> {
> return this.currentSolution;
> }
>
> #region Properties
>
> public Solution CurrentSolution
> {
> get { return this.currentSolution; }
> set { this.currentSolution = value; }
> }
>
> #endregion
> }
>
> --------------------------------------------------------
>
> relevant Code of VS AddIn:
>
> HttpServerChannel channel = new HttpServerChannel(8080);
> ChannelServices.RegisterChannel(channel);
>
>
RemotingConfiguration.RegisterWellKnownServiceType(typeof(SmartSpecRemoteObj
ect),
> "remoteObjectUri", WellKnownObjectMode.SingleCall);
>
> SmartSpecRemoteObject remObj = new SmartSpecRemoteObject();
>
> remObj.CurrentSolution = this.applicationObject.Solution;
> ObjRef ref1 = RemotingServices.Marshal(remObj, "remoteObjectUri");
>
> --------------------------------------------------------
>
> and the relevant code of th CLient Word AddIn:
>
> HttpClientChannel channel = new HttpClientChannel();
> ChannelServices.RegisterChannel(channel);
>
> SmartSpecRemoteObject remoteObject =
> (SmartSpecRemoteObject)Activator.GetObject(typeof(SmartSpecRemoteObject),
> "http://localhost:8080/remoteObjectUri");
>
> My Problem is, the property I create in VS is not sent to Word. Also
> it could be, that in Word there is a new Object without the Property
> created. I don''t know, but there is no remoteObject.CurrentSollution
> in Word, and to have this was my aim to to all this remote stuff!
>
> Perhaps someone of you has an idea to help me to get a curent
> VisaulStudio Solution to Word,
>
> Thank you,
> Kai