Solved

Developing a strong named library in C# that meets ComVisibility requirements

Posted on 2008-10-03
2
1,042 Views
Last Modified: 2013-12-17
I have been trying to develop a library (DLL) in Visual Studio 2008 and C# that could be used by a PowerBuilder application that we have in-house at our organization. I've developed a simple library just to test the concept. I've successfully compiled the library, including checking "Sign the Assembly" with a strong name key file in the project properties. I then registered the assembly with the GAC utility (gacutil), and that was successful, too.

Now, when I attempt to use the assembly in a test app (also .NET), I get the following error:

"Invalid ServicedComponent-derived classes were found in the assembly.
(Classes must be public, concrete, have a public default constructor, and meet all other ComVisibility requirements)"

I've attached the entire code for the class library, but I can't figure out what about it doesn't meet ComVisibility requirements. It has a default constructor, it all the required methods and properties are public. What's missing?
using System;
using System.Collections.Generic;
using System.EnterpriseServices;
using System.Linq;
using System.Text;
[assembly: Description("Sample DLL application to test the viability of using a DLL CrewManager Interface")]
 
namespace NIIPCrewManager
{
    [Transaction(TransactionOption.RequiresNew)]
    public class CMJob : ServicedComponent
    {
        private string m_WorkRequestNumber = string.Empty;
        private string m_CrewManagerNumber = string.Empty;
 
        #region Constructors
        /// <summary>
        /// Constructor of this class without arguments.
        /// </summary>
        public CMJob()
        {
        }
 
        /// <summary>
        /// Constructor of this class with arguments.
        /// </summary>
        public CMJob(string p_WorkRequestNumber)
        {
            m_WorkRequestNumber = p_WorkRequestNumber;
        }
        #endregion
 
        #region PUBLIC PROPERTIES
 
        /// <summary>
        /// Gets / Sets the NIIP Work Request for the job.
        /// </summary>
        public string WorkRequestNumber
        {
            get { return m_WorkRequestNumber; }
            set { m_WorkRequestNumber = value; }
        }
 
        /// <summary>
        /// Gets / Sets the CrewManager Job Number for the job.
        /// </summary>
        public string CrewManagerNumber
        {
            get { return m_CrewManagerNumber; }
            set { m_CrewManagerNumber = value; }
        }
 
        #endregion
 
        #region PUBLIC METHODS
 
        /// <summary>
        /// Creates the CrewManager Job and returns the CrewManager Job Number.
        /// </summary>
        public string CreateCrewManagerJob()
        {
            CrewManagerNumber = "TST1234";
 
            return CrewManagerNumber;
        }
 
        /// <summary>
        /// Creates the CrewManager Job and returns the CrewManager Job Number.
        /// </summary>
        public string CreateCrewManagerJob(string p_WorkRequestNumber)
        {
            WorkRequestNumber = p_WorkRequestNumber;
            CrewManagerNumber = "TST1234";
 
            return CrewManagerNumber;
        }
 
        #endregion
 
    }
}

Open in new window

0
Comment
Question by:DanielBorson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 19

Accepted Solution

by:
elimesika earned 250 total points
ID: 22642308
HI

Do the following

1) remove the class constructor that has a parameter (it should have just the default empty constructor)

2) Compile your project

3) in your test application , create the object , use the object property to set the value of WorkRequestNumber

You are not being able to call a constructor that has your parameters, but it's the price you pay to implement the ServicedComponent model.
0
 

Author Comment

by:DanielBorson
ID: 22764540
Thanks. We ended up re-doing this as a web service, but your answer makes perfect sense.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question