473,324 Members | 2,248 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,324 software developers and data experts.

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.Encryption
{
#region COM Callable Wrapper (CCW)
[Guid("F8B65FF9-7D84-4b27-BEC7-8FFF31AA6C5E"),
InterfaceType(ComInterfaceType.InterfaceIsIDispatc h)]
public interface _Symmetric
{
[DispId(1)] string EncryptString(enumCryptoServiceProvider
enumCryptoProvider, string strClearText, string strKey, string strSalt);
[DispId(2)] string DecryptString(enumCryptoServiceProvider
enumCryptoProvider, string strCipherText, string strKey, string strSalt);
// This wont work because you can't create an interface to a type
//[DispId(3)] enum enumCryptoServiceProvider;
}
#endregion
[Guid("F8B75FD9-7D84-4b27-BEC7-8FFF31AA6C5E"),
ClassInterface(ClassInterfaceType.None), ProgId("App.Class")]
public class Symmetric : _Symmetric
{
#region Declarations and enumerations
public enum enumCryptoServiceProvider : int
{//}
public Symmetric()
{
//return;
}
#endregion
#region Encryption routines
private static SymmetricAlgorithm
GetCryptoProvider(enumCryptoServiceProvider enumCryptoProvider)
{//}
private static void ConfigureOptions(SymmetricAlgorithm objCrypto, string
strKey, string strSalt)
{//}
public static string EncryptString(enumCryptoServiceProvider
enumCryptoProvider, string strClearText, string strKey, string strSalt)
{//}
public static string DecryptString(enumCryptoServiceProvider
enumCryptoProvider, string strCipherText, string strKey, string strSalt)
{//}
#endregion
}
}
Hope all this makes sense.... and thanks in advance...
Nov 30 '06 #1
1 3371
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************@nochanceinhelloffindingmehere.comw rote in message
news:%2****************@TK2MSFTNGP02.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.Encryption
{
#region COM Callable Wrapper (CCW)
[Guid("F8B65FF9-7D84-4b27-BEC7-8FFF31AA6C5E"),
InterfaceType(ComInterfaceType.InterfaceIsIDispatc h)]
public interface _Symmetric
{
[DispId(1)] string EncryptString(enumCryptoServiceProvider
enumCryptoProvider, string strClearText, string strKey, string strSalt);
[DispId(2)] string DecryptString(enumCryptoServiceProvider
enumCryptoProvider, string strCipherText, string strKey, string strSalt);
// This wont work because you can't create an interface to a type
//[DispId(3)] enum enumCryptoServiceProvider;
}
#endregion
[Guid("F8B75FD9-7D84-4b27-BEC7-8FFF31AA6C5E"),
ClassInterface(ClassInterfaceType.None), ProgId("App.Class")]
public class Symmetric : _Symmetric
{
#region Declarations and enumerations
public enum enumCryptoServiceProvider : int
{//}
public Symmetric()
{
//return;
}
#endregion
#region Encryption routines
private static SymmetricAlgorithm
GetCryptoProvider(enumCryptoServiceProvider enumCryptoProvider)
{//}
private static void ConfigureOptions(SymmetricAlgorithm objCrypto, string
strKey, string strSalt)
{//}
public static string EncryptString(enumCryptoServiceProvider
enumCryptoProvider, string strClearText, string strKey, string strSalt)
{//}
public static string DecryptString(enumCryptoServiceProvider
enumCryptoProvider, 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
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...
6
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 =====================================================================...
5
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...
1
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...
2
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)...
16
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...
102
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...
2
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...
8
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...
1
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.