PDA

View Full Version : Error when accessing Remote Serviced Components


als
07-16-2007, 06:54 PM
Hi,

Not sure whether it is a bug.

I am trying to get the Calculator example to work with COM+ services. I've got it working in the scenario where the client and the server deployed on one machine. The problem begins when I deploy server component on a separate machine and try to access it remotely.

Here is how I deployed it (.Net Framework 1.1, VS.2003):

On Server machine:
1. Copied output of the Spring.Calculator.RegisterComponentServices.2003 to remote machine and registered it via Spring.Calculator.RegisterComponentServices.exe.

2. In the COM+ services changed the folowing:
- Unchecked the "Enforce access checks..." in the security tab
- Selected "Network Services..." in the Identity tab

3. Exported Calculator App as a proxy

On Client Machine: Installed Calculator Server Proxy generated in step 3 into COM+.

So far so good. Then I tried to run the client and got the following error:

"Spring.Objects.Factory.ObjectCreationException: Error creating object with name
'' : IFactoryObject threw exception on object creation. ---> System.IO.FileNotFo
undException: The system cannot find the file specified... "

I've noticed that the error was coming from this statement in the ServicedComponentFactory:

private object CreateInstance()
{
object instance = Activator.CreateInstance(componentType);
...
}

The componentType at that point was set to "System.__ComObject" whether in the scenario where the client and the server were deployed on one machine it was set correctly to "calculatorComponent".

I've also noticed that the componentType was being set using the following statement:

componentType = Type.GetTypeFromProgID(Name, Server);

Not sure if this is the cause of the problem but I remember that I've read somewhere that the Type.GetTypeFromClsid should be used in the case of the accessing remote COM+ objects.

Any suggestons would be much appreciated.

Thank you.

P.S. The deployment process that I used above proved to be working as I used it to deploy the calculator-like sample without involving Spring and everything worked fine for both local and remote access.

als
07-16-2007, 11:27 PM
The problem was is that it looks like I did not register the Spring.Calculator.Contract.dll on the server machine. Anyway for those who is interested or for the beginners like myself here are the steps to get it working:

1. Build the Calculator sample
2. Copy output of the Spring.Calculator.RegisterComponentServices.2003 project to remote machine (any location)
3. Register components in the GAC:
gacutil -i Spring.Calculator.EnterpriseServices.dll
gacutil -i Spring.Calculator.Contract.dll

4. Run Spring.Calculator.RegisterComponentServices.exe
or
regsvcs Spring.Calculator.EnterpriseServices.dll

5. Go to COM+ console and update Identity and Security as follows (Security can configured later of course):

Set Identity to: "Network Service - Built-in account..."
Uncheck "Enforce Access checks..."

6. Export the app as the proxy. It should produce an MSI file

On the client machine:

1. Copy MSI file to Client machine
2. Go to COM+ and install pre-build app from the MSI file
3. Run the Client project from the Calculator solution. It should work now i.e. you should see the following output:

--- Press <return> to continue ---
Get Calculator...
Divide(11, 2) : Quotient: '5'; Rest: '1'
Memory = 0
Memory + 2 = 0
Get Calculator...
Memory = 0
--- Press <return> to continue ---
Press any key to continue

P.S. Forgot to mention that to register Com+ app automatically as a Server I modified the enterpriseServices.xml configuration file that exports Calculator Service as a components as follows (in bold):

<object type="Spring.EnterpriseServices.EnterpriseServicesExport er, Spring.Services">
<property name="ApplicationName">
<value>Spring Calculator Application</value>
</property>
<property name="Description">
<value>Spring Calculator application.</value>
</property>
<property name="ActivationMode">
<value>Server</value>
</property>
...
</object>