0
votes

I have a class "Settings" written in VB.NET. I am trying to use this class in a console application written in C#. When I instantiate Settings class in my console application I am getting this exception:

'System.UnauthorizedAccessException' in System.EnterpriseServices.Wrapper.dll An unhandled exception of type 'System.UnauthorizedAccessException' occurred in System.EnterpriseServices.Wrapper.dll Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

I have tried changing launch and activation permissions in DCOM Config.


    class Program
        {
            static void Main(string[] args)
            {
                SqlConnection CN = null;
                Settings S = new Settings();// Exception throws here
                CN = new SqlConnection(S.GetLocalSetting("CnStr"));
            }
        }

Settings class imports these namespaces:

 Imports System.IO
 Imports System.EnterpriseServices
 Imports System.Xml
 Imports Data.Encryption

// Constructor
Public Sub New()

    End Sub

And has many methods which are used to get and delete settings, to connect to database etc.

1
It seems like a permissions issue... Can you show the Settings class?zaggler
I also think it must be a file permission issue. Please make sure that you have access to the file you want to use.Lajos Arpad
@Çöđěxěŕ I have edited the question to give you some insight about settings class.RoshanJha
@Çöđěxěŕ I added the constructor. Class does not do anything inside the constructor.RoshanJha
It's definitely a permission issue (one of the imports/namespaces) as I mentioned before, try running VS as an Administrator.zaggler

1 Answers

0
votes

The classes in Data.Encryption requires administrator permissions to run, and that's why you got this exception.

You try run your visual studio in administrator mode?