Results 1 to 4 of 4

Thread: How to make Activex.dll safe in C#

  1. #1
    Join Date
    Feb 2009
    Posts
    35

    How to make Activex.dll safe in C#

    I have created a Activex dll in c# using Visual Studio 2005 by marking the component as "Mark as COM visible" in the compile properties of project. I will be using this code in the javascript. Now I want to mark this activex dll as safe. I have searched in the net and came to know the two possible solutions for doing this are: -

    1. Implement IObjectSafety interface
    2. Add a typical CLSID values in the DllRegistryMethod of activex registration.

    But no where step by step instructions were given for doing this. Please help me in marking the activex dll as safe which was developed in c# using Microsoft Visual Studio 2005.

    Thanks,

  2. #2
    Join Date
    Mar 2008
    Posts
    258

    Re: How to make Activex.dll safe in C#

    Is the ActiveX for the client, or for the server?

    If for the server, just use a direct reference to the managed assembly (no need for COM).

    Re the client, frankly I'm not sure it is a good idea to be writing ActiveX controls - most browsers won't love them. You'd do better with AJAX and DHTML, or Silverlight / Acrobat / etc for something more complex.

    [update] So you want ActiveX at the client... my next though would be "can Silverlight access the certificate store?" I can't find anything, though...

    Distributing an ActiveX control (for IE) is usually a matter of packaging the dll into a cab, marking it as safe for scripting and safe for activation. You then place the cab on the web-server, and on the edge you have an <object...>...</object> element specifying the source (code-base) of the cab.

    I have to stress that this approach is going to be very hit-and-miss; it won't work on many browsers, and will work some of the time on IE (depending on the user's security settings). I don't recommend it.

    A more practical option might be to write a standalone .NET exe that you package via ClickOnce ("Publish" in VS); drop the ClickOnce deployment on the web-site, and navigate to the application. check - full .NET code at the client, without the browser issues.

  3. #3
    Join Date
    Jan 2006
    Posts
    211

    Re: How to make Activex.dll safe in C#

    Working with .dlls isn't difficult, but a few simple tips should make your experience smoother. Don't forget that you must register a .dll to use it. To register an ActiveX .dll, use the Windows API call:
    Public Declare Function .DLLSelfRegister Lib "vb6stkit.dll" (By Val lp.dllName As String) As Integer

    After modifying a .dll, you may need to re-register it if you added a new class or you copy the source to another development computer (something you should try to avoid). Compiling an ActiveX .dll assigns a unique identifier to the file. If you copy the source to another machine and then compile it there, the identifier changes to reflect the current computer. Consequently, each time you copy the .dll to the Web server, you will have to reregister it, regardless of the type of development changes you made to the source.

    Working with .dll files does require that you manually restart the server occasionally. The easiest way to manually restart Internet Information Server (IIS) is to connect via Computer Management (a Windows 2000 utility). The Web server service is called World Wide Web Publishing Service. If you have the Windows 2000 Server Resource Kit, you can use the service.vbs tool and run the batch file:
    C:
    cd\
    cscript service.vbs /X /N W3SVC /S IISmachinename
    pause
    cscript service.vbs /G /N W3SVC /S IISmachinename

    When debugging the .dll, use Visual Basic's Debug feature, which allows you to walk through your code when you load an ASP page. You can learn more about debugging Visual Basic .dll files within Visual Basic from the Microsoft Knowledge Base.

  4. #4
    Join Date
    Dec 2008
    Posts
    183

    Re: How to make Activex.dll safe in C#

    If the code is not thread-safe, then it's not thread-safe, and you'd better not call it from a web service.

    Assuming you can't get the authors to fix their code for this environment (or to rewrite in managed code), then you should consider creating a separate server for that DLL and communicating between the Web Service and this separate service using .NET Remoting. In effect, you'll need to make sure that the DLL is only ever accessed from a single thread, from the time it's initialized, through all of the calls, to the time it is uninitialized.

    Still, let's not get ahead of ourselves on the threading. You still haven't told me exactly what the problem is - what variable is being set to Nothing when you expected it to be set to something else?

Similar Threads

  1. How to a use print spooler and make it start in safe mode
    By Bageshri27 in forum Hardware Peripherals
    Replies: 5
    Last Post: 24-06-2011, 06:53 AM
  2. Is it safe to make Skype video call?
    By %Achan in forum Windows Software
    Replies: 4
    Last Post: 10-02-2011, 10:24 PM
  3. Zynga Poker: How to make your Account Safe?
    By $Daiwik$ in forum Video Games
    Replies: 4
    Last Post: 02-02-2011, 10:21 AM
  4. Make kids safe when they surf the Internet
    By Kraker999 in forum Technology & Internet
    Replies: 5
    Last Post: 05-05-2010, 08:45 AM
  5. How to make computer safe from the children use?
    By Dolsy_bendal in forum Windows Software
    Replies: 4
    Last Post: 21-01-2010, 05:30 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,718,399,620.26010 seconds with 17 queries