473,378 Members | 1,447 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

COM+ Interface Error

(If Im posting in the wrong place concerning COM+ and .NET plz redirect me.)

Hello all,

Im writing a COM+ in VB.NET that is suppose to be able to set/get an
address(String value).

I've made a seperate project that contains all interfaces Im using in my
entire project. But whenever I try to include the Interface in the COM+ class
the initialization of the COM+ object fails. I get an exception.

This is how the Interface looks
-------------------------------INTERFACE----------------------------------------------
<Assembly: AssemblyKeyFile("C:\InterfaceKey.snk")>

<Guid("1A3D56B8-9D12-1A34-1AF4-12AEF7654321"), _
InterfaceType(ComInterfaceType.InterfaceIsIDispatc h), _
DataSysDescription("The Shared Property Manager(SPM) announces its
Object URI address")> _
Public Interface ICentralSPM
<DispId(1), _
DataSysDescriptionAttribute("Sets the object URI address")> _
Function SetCentralPrimary(ByVal strObjectURI As String) As Boolean

<DispId(2), _
DataSysDescriptionAttribute("Gets the object URI address")> _
Function GetCentralPrimary(ByRef strObjectURI As String) As Boolean

End Interfac
-------------------------------INTERFACE----------------------------------------------

And my COM+ project looks like this :
-----------------------------COM+
Project---------------------------------------------
Imports System.EnterpriseServices
Imports System.Runtime.InteropServices

<Assembly: ApplicationAccessControl(True)>
<Assembly: AssemblyKeyFile("C:\COMPluskey.snk")>
<Assembly: ApplicationName("MyCOMPlus")>
<Assembly: ApplicationActivation(ActivationOption.Server)>

<Guid("1AB45AB8-12AB-12A4-1ABD-12AB87654321"), _
JustInTimeActivation(True), _
ComponentAccessControl(True), _
SecurityRole("Master"), _
SecurityRole("Guest", True)> _
Public Class clsSPM
Inherits ServicedComponent
Implements prjCentralSPM.ICentralSPM

Public Function SetCentralPrimary(ByVal strObjectURI As String) As
Boolean Implements prjCentralSPM.ICentralSPM.SetCentralPrimary
Dim oSPMManager As SharedPropertyGroupManager
Dim oSPMGroup As SharedPropertyGroup
Dim oSPMProperty As SharedProperty
Dim bExists As Boolean
Dim bRetVal As Boolean = False
Dim bValidate As Boolean = True

Try
If Me.Validate Then
oSPMManager = New SharedPropertyGroupManager
oSPMGroup = oSPMManager.CreatePropertyGroup("MySPM",
PropertyLockMode.SetGet, PropertyReleaseMode.Process, bExists)
' Does not matter if it exists or not
' Call to create will do check for me
oSPMProperty =
oSPMGroup.CreateProperty("CentralPrimaryAddress", bExists)
oSPMProperty.Value = strObjectURI
End If
Catch ex As Exception
'TODO: Error logging
Finally
oSPMProperty = Nothing
oSPMGroup = Nothing
oSPMManager = Nothing
End Try

End Function

Public Function GetCentralPrimary(ByRef strObjectURI As String) As
Boolean Implements prjCentralSPM.ICentralSPM.GetCentralPrimary
Dim oSPMManager As SharedPropertyGroupManager
Dim oSPMGroup As SharedPropertyGroup
Dim oSPMProperty As SharedProperty
Dim bExists As Boolean
Dim bRetVal As Boolean = False
Dim bValidate As Boolean = True
Try

strObjectURI = ""

If Me.Validate Then
oSPMManager = New SharedPropertyGroupManager
oSPMGroup = oSPMManager.CreatePropertyGroup("MySPM",
PropertyLockMode.SetGet, PropertyReleaseMode.Process, bExists)

If bExists = True Then
oSPMProperty =
oSPMGroup.CreateProperty("CentralPrimaryAddress", bExists)
strObjectURI = IIf(IsNumeric(oSPMProperty.Value), "",
oSPMProperty.Value)
If strObjectURI.Length > 0 Then
bRetVal = True
End If
End If
Else
bValidate = False
End If
Catch ex As Exception
'TODO: Error logging
Finally
oSPMProperty = Nothing
oSPMGroup = Nothing
oSPMManager = Nothing
End Try
'If bValidate is false means unauthorized person tried to get CPS
Central .NET Object URI
If bValidate = False Then
Throw New System.Exception("Unauthorized User")
End If

Return bRetVal
End Function
Private Function Validate() As Boolean
'Basically checks if the person who is calling has authority.
'The IsCallerInRole returns true if the AccountName (ex:
"domain\username") exists under Master->Users in Component Services
Dim bRetVal As Boolean = False
Try
If ContextUtil.IsSecurityEnabled Then
If SecurityCallContext.CurrentCall.IsCallerInRole("Ma ster")
= True Then
bRetVal = True
End If
End If
Catch ex As Exception
'TODO: Error logging
End Try
Return bRetVal
End Function
Public Function GetAccountName() As String
'Basically return the account name ex "domain\username"
If ContextUtil.IsSecurityEnabled Then
Return SecurityCallContext.CurrentCall.OriginalCaller.Acc ountName
End If
End Function

End Class
-----------------------------COM+
Project---------------------------------------------

After registering the COM+ application successfully using regsvcs I try
creating the Object:
-----------------Client--------------
.....
Private m_comSPM As MyCOMPLus.clsSPM
......
Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'The following line gets an exception:
Me.m_comSPM = New MyCOMPLus.clsSPM
End Sub
....
-----------------Client--------------

I get the following Exception :

------------------Exception--------------

An unhandled exception of type 'System.IO.FileNotFoundException' occurred
in mscorlib.dll

Additional information: File or assembly name prjCentralSPM, or one of
its dependencies, was not found.
------------------Exception--------------

If remove everything that has to do with the interface, i.e. implements
those functions without using the line "Implements prjCentralSPM.ICentralSPM"
it all works great.

I've compared prjCentralSPM, MyCOMPlus and my Test project and they all have
the same references added. So basically clueless why I cant include the
Interface in the COM+. As a side note when I do include the interface I can
see it in Component Services and it lists the two methods under
Interfaces->ICentralSPM.

Anybody know how to use Interfaces compiled in seperate projects in COM+?

Best Wishes,
Farek
Jul 21 '05 #1
0 1402

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Mikko Ohtamaa | last post by:
Hi, I am quite new to Python, PythonCom and COM generally. As a former Java programmer, I have found Python's flexible ability to access native Win32, especially COM, very comfortable. However,...
3
by: Davide M3xican Coppola | last post by:
Hi, I would realize an interface (interface) for a pair of concrete classes (concrete & concrete2), but I have a problem because I have to access to a third class (element) and if I try to declare...
4
by: Doug | last post by:
I am working on an existing .NET (C Sharp) component that had a com interface that was used by a VB component. When it was originally written, it had the SSEAssemblyCom class below - minus the two...
7
by: yufufi | last post by:
lets say we have a 'shape' class which doesn't implement IComparable interface.. compiler doesn't give you error for the lines below.. shape b= new shape(); IComparable h; h=(IComparable)b;...
15
by: Carlos Lozano | last post by:
Hi, What is the right way to create an OCX COM component. The component is already registerred, but can't create an instance. I am using the reference to the interop module created. If I use...
5
by: platinumbay | last post by:
Two questions: 1) I have an VB.NET application that moves files, loads them in DTS, and updates a custom SQL database queue. I want to move everything into COM+ to be XA compliant. I built the...
0
by: Farek | last post by:
(If Im posting in the wrong place concerning COM+ and .NET plz redirect me.) Hello all, Im writing a COM+ in VB.NET that is suppose to be able to set/get an address(String value). I've made...
10
by: Bryce Calhoun | last post by:
Hello, First of all, this is a .NET 1.1 component I'm creating. SUMMARY ----------------------- This component that I'm creating is, for all intents and purposes, a document parser (I'm...
0
by: =?Utf-8?B?UmFodnlu?= | last post by:
Hi All; I am writing a COM interface that will need to be called from VBScript (Legacy App). I need to return a recordset to the calling app. I am using ADODB to populate the recordset and...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.