I have a C# class library and also have a powerbuilder application. I want to expose the c# class and use it in the powerbuilder application. I used the following blogs to expose the functions so it can be accessed by powerbuilder application
https://whoisburiedhere.wordpress.com/2011/07/12/creating-a-com-object-from-scratch-with-c/
http://jumbloid.blogspot.com/2009/12/making-net-dll-com-visible.html
So i exposed the COM and made it accessible in powerbuilder but i still have some fundamental questions to make sure if i follow the best guidelines. The class looks before converting to COM looks like
class classname
{
function1(){//do something}
function2(){//do something}
function3(){//do something}
function4(){//do something}
}
To convert to COM I created an interface and i wanted to expose only function1 and function2. So i modified the class as
[ComVisible(true)]
[Guid("03S3233DS-EBS2-5574-825F-EERSDG8999"),InterfaceType(ComInterfaceType.InterfaceIsDual)]
interface Iinterface
{
function1();
function2();
}
In the main class i made the following modifications
1. I set the COM visible property to false in AssemblyInfo as i do not want to expose all the public methods.
2. Class looks like
[ComVisible(true)]
[Guid("2FD1574DS4-3FEA-455e-EW60A-EC1DFS54542D"), ClassInterface(ClassInterfaceType.None)]
class class1 : Iinterface
{
function1(){//do something}
function2(){//do something}
[ComVisible(false)] //i don't want the mehtod to be exposed
function3(){//do something}
[ComVisible(false)]
function4(){//do something}
}
I have the following questions for me to understand better
1. Do i explicitly set the COM visible property to false for the methods that i do not want to expose if i set the visible property of class to true and the default COM visible property (in assemblyinfo) to false? My understanding is i will only have functions that i want to expose in interface, so irrespective of the visible property, if i dont have the function in interface then it won't be visible? I did understand how to deploy using regasm in client computer by copying the dll and use regasm.exe, my question is how to deploy in non development machines with no .NET installed?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…