473,890 Members | 1,192 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem creating CCW

Kev
Gidday,

I am stuck trying to create a COM Callable Wrapper for the class (shell
only) below.

As you can see I have tried to define my interface and it would be all good
if I wasn't passing my enum into the main functions (which are marked public
static). I am unable to create an interface for the enum, and I can't mark
it as public static so not sure how to get the compiler to swallow it.

I'd rather not have to pass the enum to the functions as an integer as I
think this will break intellisense when calling the function (meaning I
don't think it will display the enumerated list which is a nice feature).
Also, I want this component to be stateless so I need to be able to specify
the crypto provider (the enumerated value) as part of the function call.
Lastly, I prefer a declarative approach so not really interested in just
enabling COM functionality under Project -Properties.

Here's what I have so far (roughly - bit of a cut and paste so forgive any
obvious errors):

using System;
using System.Text;
using System.Runtime. InteropServices ;
using System.Security .Cryptography;
namespace SomeNamespace.E ncryption
{
#region COM Callable Wrapper (CCW)
[Guid("F8B65FF9-7D84-4b27-BEC7-8FFF31AA6C5E"),
InterfaceType(C omInterfaceType .InterfaceIsIDi spatch)]
public interface _Symmetric
{
[DispId(1)] string EncryptString(e numCryptoServic eProvider
enumCryptoProvi der, string strClearText, string strKey, string strSalt);
[DispId(2)] string DecryptString(e numCryptoServic eProvider
enumCryptoProvi der, string strCipherText, string strKey, string strSalt);
// This wont work because you can't create an interface to a type
//[DispId(3)] enum enumCryptoServi ceProvider;
}
#endregion
[Guid("F8B75FD9-7D84-4b27-BEC7-8FFF31AA6C5E"),
ClassInterface( ClassInterfaceT ype.None), ProgId("App.Cla ss")]
public class Symmetric : _Symmetric
{
#region Declarations and enumerations
public enum enumCryptoServi ceProvider : int
{//}
public Symmetric()
{
//return;
}
#endregion
#region Encryption routines
private static SymmetricAlgori thm
GetCryptoProvid er(enumCryptoSe rviceProvider enumCryptoProvi der)
{//}
private static void ConfigureOption s(SymmetricAlgo rithm objCrypto, string
strKey, string strSalt)
{//}
public static string EncryptString(e numCryptoServic eProvider
enumCryptoProvi der, string strClearText, string strKey, string strSalt)
{//}
public static string DecryptString(e numCryptoServic eProvider
enumCryptoProvi der, string strCipherText, string strKey, string strSalt)
{//}
#endregion
}
}
Hope all this makes sense.... and thanks in advance...
Nov 30 '06 #1
1 3393
Kev
I take it from the overwhelming volume of replies that either nobody has any
idea what I am talking about (probably my fault), or nobody has an answer.

Well guess what, I do. I figured out the problem was that the methods I
wanted to display through my interface were declared public static which is
not allowed for interfaces (try finding that bit of info easily... took me a
while...).

However, I wanted those methods to be public static... so I was stuck on how
to have them public static while also allowing use from VB6 and COM. In the
end I compromised and reverted my original crypto class back to before I
applied the CCW. I then created a new class with the same name but ending
with _COM and added the two methods I wanted to expose to COM with the same
method signature (parameters etc) but only the public modifier (no static).

In each method I simply passed the parameters to the public static methods
in the .Net class and passed the returned string back to the caller. Simple,
1 line of code in each mothod.

Then I applied the CCW to that class. Because it only had public methods the
compiler was nice and happy.

The end result is a .Net component that can have the methods called without
an object instance, and the same methods available via COM but requiring an
object instance. Like I said, a compromise. But one I can live with as I
rarely do COM these days.

If anybody has any interest in this I'll post the code.

Cheers

"Kev" <sp************ @nochanceinhell offindingmehere .comwrote in message
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
Gidday,

I am stuck trying to create a COM Callable Wrapper for the class (shell
only) below.

As you can see I have tried to define my interface and it would be all
good if I wasn't passing my enum into the main functions (which are marked
public static). I am unable to create an interface for the enum, and I
can't mark it as public static so not sure how to get the compiler to
swallow it.

I'd rather not have to pass the enum to the functions as an integer as I
think this will break intellisense when calling the function (meaning I
don't think it will display the enumerated list which is a nice feature).
Also, I want this component to be stateless so I need to be able to
specify the crypto provider (the enumerated value) as part of the function
call. Lastly, I prefer a declarative approach so not really interested in
just enabling COM functionality under Project -Properties.

Here's what I have so far (roughly - bit of a cut and paste so forgive any
obvious errors):

using System;
using System.Text;
using System.Runtime. InteropServices ;
using System.Security .Cryptography;
namespace SomeNamespace.E ncryption
{
#region COM Callable Wrapper (CCW)
[Guid("F8B65FF9-7D84-4b27-BEC7-8FFF31AA6C5E"),
InterfaceType(C omInterfaceType .InterfaceIsIDi spatch)]
public interface _Symmetric
{
[DispId(1)] string EncryptString(e numCryptoServic eProvider
enumCryptoProvi der, string strClearText, string strKey, string strSalt);
[DispId(2)] string DecryptString(e numCryptoServic eProvider
enumCryptoProvi der, string strCipherText, string strKey, string strSalt);
// This wont work because you can't create an interface to a type
//[DispId(3)] enum enumCryptoServi ceProvider;
}
#endregion
[Guid("F8B75FD9-7D84-4b27-BEC7-8FFF31AA6C5E"),
ClassInterface( ClassInterfaceT ype.None), ProgId("App.Cla ss")]
public class Symmetric : _Symmetric
{
#region Declarations and enumerations
public enum enumCryptoServi ceProvider : int
{//}
public Symmetric()
{
//return;
}
#endregion
#region Encryption routines
private static SymmetricAlgori thm
GetCryptoProvid er(enumCryptoSe rviceProvider enumCryptoProvi der)
{//}
private static void ConfigureOption s(SymmetricAlgo rithm objCrypto, string
strKey, string strSalt)
{//}
public static string EncryptString(e numCryptoServic eProvider
enumCryptoProvi der, string strClearText, string strKey, string strSalt)
{//}
public static string DecryptString(e numCryptoServic eProvider
enumCryptoProvi der, string strCipherText, string strKey, string strSalt)
{//}
#endregion
}
}
Hope all this makes sense.... and thanks in advance...

Dec 1 '06 #2

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

Similar topics

0
2998
by: RJS | last post by:
Hi all, I can't get a py2exe compiled app to run with numarray (numarray-0.5.win32- py2.2). Also wxPythonWIN32-2.3.3.1-Py22 and ActivePython-2.2.1-222. In the sample below, commenting out "import numarray" allows the exe to run. Left in, I get "4.exe has generated errors" etc. I'm going around and around and there isn't much on Google. py2exe output is last.
6
683
by: Club-B42 | last post by:
i've compiled my programm using command "python setup.py py2exe >1" python script works fine, but .exe version fails with ===================================================================== D:\\Scripts\B-4-2\la2luncher\dist>la2launcher.exe Traceback (most recent call last): File "la2launcher.py", line 9, in ? File "config.pyc", line 11, in ? File "config.pyc", line 8, in u LookupError: no codec search functions registered: can't find...
5
1281
by: יוני גולדברג | last post by:
Hi, While trying to create new directory i recieve the following error message: "System.IO.DirectoryNotFoundException: Could not find a part of the path "\\premfs16\sites". The path exists, even when i check the path with the code: Directory.Exists(...) the result is true. Here is the code: http://www.adeo.co.il/test.aspx
1
2064
by: Medora Schauer | last post by:
I've installed 7.4.2 on a PowerPC system running linux 2.4.13. When I try to run initdb to create to create the database cluster I get the following: $ initdb -D $PGDATA The files belonging to this database system will be owned by user "thebox".
2
1946
by: tech tech | last post by:
Hello All, I installed postgresql 7.3.4 on HPUX PA in /usr/local/pgsql and put the libraries in /usr/local/pgsql/lib/LIB_new. During the initialization( initdb), it loads libraries (language) from /usr/local/pgsql/lib. In postgresql version 7.3.1, libraries are not loaded and no such problem during initdb. I had the following problem: $ initdb -D /var/pgsql The files belonging to this database system will be owned by user "postgres".
16
4936
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by Microsoft must be installed on their servers. Now german Umlaute (, , ) and quotes are returned incorrectly in SOAP fault responses. This can be easily verified: Implement the following in a web service method (just raises a SOAPException with a...
102
6869
by: hug | last post by:
www.webmaster, was suggested that this ng could be a better place.] I've updated my test server to handle if-modified-since. I've noticed that the (old copies I run of) IE and Netscape seem never to send if-modified-since. But the strange thing is that Opera sends if-modified-since but when I reply with "HTTP/1.0 304 Not Modified" it is not refreshing the screen from its cache, it is leaving the screen blank.
2
1209
by: JJ | last post by:
Using asp.net 1.1 I am trying to have a consistent look for the webcontrols. Right now, every time I use textbox controls, I manually change the font property, size property, and other property to the default values that I use for all webcontrols. So a lot of manual work. To streamline the process, I see two possibilities. 1. Would it be better to do this by extending a textbox control by creating my own control (ie creating a web...
8
8953
by: Chizl | last post by:
I'm building a web server and having some issues with the TCPListener.Start(BackLog). It doesn't seem to do as expected. I'm using MS Web Stress Tool to test against my web server and when I see 200 connections at once to it, and I'm seeing 2/3 of the sockets as socket errors.. They never get into my code, so it has to be failing on the connection side.. Backlog is the only thing I can think could be the problem. ...
1
2856
by: Ana RM | last post by:
Mark.Powell@eds.com (Mark D Powell) wrote in message news:<2687bb95.0308010642.1fc4ff1f@posting.google.com>... Hi Mark, Thanks por answer me. I do not think it is important thw warehouse knowledge to solve my problem because at the end all the tables are relational. The point is that I do not want make changes in the database, I want
0
9820
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11227
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10462
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9630
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7169
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5848
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4676
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4270
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3276
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.