Hi to all I'm writing an ActiveX in C#, I found a great tutorial in:
http://www.c-sharpcorner.com/UploadFile/dsandor/ActiveXInNet11102005040748AM/ActiveXInNet.aspx
The problem is that my ActiveX should create a folder and do some another actions in the Client machine, according what I know when the user allow using ActiveX, the ActiveX has permissions to do every thing. When I click on the button that should create the folder I receive an error:
Application attempted to perform an operation not allowed by the security policy. To grant this application the required permission, contact your system administrator, or use the Microsoft .NET Framework Configuration tool.
See attached picture.
What I should perform, to allow to ActiveX to run properly?
Thanks in advanced.

Dani AI

Generated

Short summary and practical path forward for : a C# ActiveX hosted in Internet Explorer runs under the CLR and is subject to the framework's trust model. The browser prompt alone does not automatically grant rights to touch the client file system or start other programs. To get those capabilities the control must be deployed and granted full trust on each client machine (not just built on the developer machine).

What to do (high level, in order)

  • Make the assembly COM-visible and give it a stable identity (strong name or GUID).
  • Deploy a signed CAB or an installer that registers the COM types on the client (RegAsm or MSI). Registration plus a certificate that clients trust is required for smooth install.
  • Give the code FullTrust on client machines. That is usually done by trusting the publisher certificate on the client (Trusted Publishers) or by adding a FullTrust grant in machine policy (caspol / Group Policy or an installer that adjusts policy). Putting the assembly in the GAC is another option where appropriate.
  • If the control needs to launch an EXE, that call must run under full trust; the code to start a process is the usual System.Diagnostics approach.

Useful commands to test locally

rem register the managed COM assembly for testing (requires admin)
regasm "C:\Path\MyActiveX.dll" /codebase /tlb

Example of the process-start call your control would use (requires full trust)

System.Diagnostics.Process.Start(@"C:\Path\app.exe");

Troubleshooting and cautions

  • Test on a clean client VM: register the assembly and run IE elevated to confirm behavior before trying to deploy to users.
  • Examine SecurityException stack traces and Event Viewer to see exactly which permission is blocked.
  • Modern browsers (and many corporate policies) block or disallow ActiveX; distributing an ActiveX that launches arbitrary EXEs is high-risk. Consider safer alternatives: ClickOnce, a signed native helper application with a custom URL protocol, or an installer deployed via Group Policy.

Notes for : implementing an in-browser control in C# is possible, but for launching local EXEs a small installed helper or ClickOnce is normally the safer, more compatible route than relying on ActiveX.

Recommended Answers

All 3 Replies

Yes, according to your .net security, you don't give the user permissions to access protected resources, configure it from Control panel->Administrative tools->Microsoft .NET Framework 2.0 Configuration.
You may need to configure the zone of the application, work around this you'll solve this problem :)

Hi, thanks for response.
But still I have the same problem.
What I don't understand is, I should give permissions to my ActiveX in my computer? What will happen when user runs the ActiveX in his computer?
BTW - I open the Microsoft .NET Framework 2.0 Configuration and I don't know what to change.
Any Ideas?
Thanks

Hi ,

I am new to c# , I want to know how to develop ActiveXControls in c# ,Can you let me know some samples if you have.

My Requirement is : to run an Exe which is residing on the Client machine .

I.e in the web page i will ask the user to select the exe path (in to a text box),
and on click of a button in webpage i want to run the exe which is on client machine(path will be in the text box)

can you tell me how to achieve this ,(Is it require activeX .. etc)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.