JScript for the .NET Framework
How to implement IObjectSafety programmatically in JScript.NET
Consider this JScript.NET library (helloworld1.js): package helloworld1{ class test1 { public function test1run(){ return 'This is a string returned from helloworld1.dll'; } }} After running it throug: jsc.exe /nologo /t:library helloworld1.js and: regasm /nologo /codebase helloworld1.dll I can use it on my local html page with: var helloworld1 = new ActiveXObject("helloworld1.test1");alert(helloworld1.test1run()); It works well but I get the usual "this is unsafe" warning from the browser: An ActiveX control on this page might be unsafe to interact with other parts of the page. Do you want to allow this interaction? I know the way to remove the security warning is to mark the dll as safe for scripting and implement IObjectSafety. I know how to do this in VB6 and VB.NET but how do I go implementing it in JScript.NET? Any help is greatly appreciated.
Hi Leo, Thanks for the link. Yeah I figured out , as there is absolutely no documentation for IObjectSafety in JScript.NET, I can't implement this directly in the code. Rather than going backward to C#, I finally settled down with adding the needed registry keys for marking my dll as "Safe for initialization" and "Safe for scripting": [HKEY_CLASSES_ROOT\CLSID\[MY_COM_CLASS_GUID]\Implemented Categories\{7DD95801-9882-11CF-9FA9-00AA006C42C4}] [HKEY_CLASSES_ROOT\CLSID\[MY_COM_CLASS_GUID]\Implemented Categories\{7DD95802-9882-11CF-9FA9-00AA006C42C4}] I add these keys during my setup routine, when helloworld1.dll is deployed on target machines. It works flawlessly. Best wishes,
Hi tony, If you write the library directly in JScript.NET, there is no approach to implement the IObjectSafety interface, because this COM interface is available in C# or C++ only. You can rewrite your library in C# and implement the IObjectSafety interface via COM interop. Here is a wonderful tutorial for you: http://www.dreamincode.net/forums/topic/38890-activex-with-c%23/. Have a nice day, Leo Liu [MSFT] MSDN Community Support | Feedback to us
Hi Leo, Thanks for the link. Yeah I figured out , as there is absolutely no documentation for IObjectSafety in JScript.NET, I can't implement this directly in the code. Rather than going backward to C#, I finally settled down with adding the needed registry keys for marking my dll as "Safe for initialization" and "Safe for scripting": [HKEY_CLASSES_ROOT\CLSID\[MY_COM_CLASS_GUID]\Implemented Categories\{7DD95801-9882-11CF-9FA9-00AA006C42C4}] [HKEY_CLASSES_ROOT\CLSID\[MY_COM_CLASS_GUID]\Implemented Categories\{7DD95802-9882-11CF-9FA9-00AA006C42C4}] I add these keys during my setup routine, when helloworld1.dll is deployed on target machines. It works flawlessly. Best wishes,
Related Links
Error in AJAX PopUp Control Extender
JavaScript to Open Word 2010
Change td width dynamically
sql and javascript
Multiple nested Modal Popups
Drag and Drop Images from a Toolbox using javascript
Microsoft jScript runtime error
how to make a screen Like this?
Not Understand javascript code compatible with IE
how to find a texbox control inside a datagrid using javascript
ajax controls similar to office on web application
Create new HTML Helper for Search button
IE7 showmodaldialog displays unnecessary scroll bar with content
Javascript client server download speed help
Help i am getting this error 'Runtime error: unable to load dll jscript." can anybody help?
scrollbar in asp ListBox control