2

I've got an .NET assembly I have built to access one of our databases and passed off to another programmer to use in their Delphi application.

On Vista and Windows 7 machines running with a user login (without Admin rights) running the Delphi EXE fails with "Ole Error 8013150A" but otherwise works on all other OS types we tested.

The Delphi EXE works when Run as Administrator.

Once the EXE has been run ONCE as Administrator, from then on it will work fine when run normally.

I'm thinking there is something in the registry that needs to be written when instantiating the COM interface in the Delphi app that requires admin rights, but once written never needs to be done again... or something along those lines?

Error 8013150A seems to be related to security errors from what little information I could find on it.

Any ideas?

Fashtas
  • 97
  • 2
  • 9
  • 2
    The Delphi code must indeed be doing something the first time it is run that needs elevated access to for example the registry. The possibilities are almost endless. Only your Delphi developers can narrow it down to what action in their code might cause this. – Marjan Venema May 17 '12 at 09:16
  • According to them, the error occurs as they instantiate the .NET library and call they INIT method. I'd been mostly concerned about the COM interface till now and hadn't thought it was something as simple as what you mentioned... Only code in the init that I can think would cause issues was a RegisterWindowMessage call... but I'll have to double check everything – Fashtas May 17 '12 at 13:32
  • 2
    This sounds like your assembly is trying to do something in the registry (`HKLM` or `HKCR`, perhaps) that needs access that the normal user doesn't have by default in Vista+. Is it creating any registry entries or perhaps opening a key in `HKLM` or `HKCR` with more than read-only rights? Registering any COM objects or classes? – Ken White May 17 '12 at 22:10

1 Answers1

1

The issue turned out to be the following code in the .NET assembly

string cs = "ANameDoesntExist";
EventLog elog = new EventLog();
if (!EventLog.SourceExists(cs))
{
    EventLog.CreateEventSource(cs, "Application");
}
elog.Source = cs;
elog.EnableRaisingEvents = true;

Just plonking this code down on a basic form will cause an System.Security.Security exception in Vista and Windows 7 machines logged on via a User account.

It will work in admin, and of course work after that in user security since it was created!

Ironically, this logging was added to try and work out why we were having other issues the code!

The error also turned up in StackOverflow here C#: Simple Windows Service gives Security Exception but of course I was initially tracking down the OLE exception!

thanks for the help

Community
  • 1
  • 1
Fashtas
  • 97
  • 2
  • 9