.NET Assembly - Needs Admin permissions to create event log  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

.NET Assembly - Needs Admin permissions to create event log

Postby mribbons » Tue Sep 02, 2014 3:50 pm

Jiwa 7.00.78

The first time I ran my .NET app I get a security exception:

The source was not found, but some or all event logs could not be searched. To create the source, you need permission to read all event logs to make sure that the new source name is unique. Inaccessible logs: Security.
at System.Diagnostics.EventLog.FindSourceRegistration(String source, String machineName, Boolean readOnly, Boolean wantToCreate)
at System.Diagnostics.EventLog.SourceExists(String source, String machineName, Boolean wantToCreate)
at System.Diagnostics.EventLogInternal.VerifyAndCreateSource(String sourceName, String currentMachineName)
at System.Diagnostics.EventLogInternal.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData)
at System.Diagnostics.EventLog.WriteEntry(String source, String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData)
at JiwaFinancials.Jiwa.JiwaApplication.Manager.ReportError(String ErrorMessage, String ErrorModule)
at JiwaFinancials.Jiwa.JiwaApplication.Plugin.PluginCollection.Compile()
at JiwaFinancials.Jiwa.JiwaApplication.Manager.Logon(String ServerName, String DatabaseName, AuthenticationModes AuthenticationMode, String JiwaUserName, String JiwaPassword)

It looks like it needs to create the JiwaApplication event source - Can this be done as part of the installation?

Further to this, every time I run a lot of events like this are created:

"Plugin Manual Serial Numbers encountered an exception when compiling or loading, and was not loaded.

The error was : The 'ReferencedAssemblies' property cannot contain null or empty strings.
Parameter name: options"

Other than this my Manager.Instance.Logon() call seems to work.
Regards,
Mike Ribbons
Micro Pacific Pty Ltd
http://www.micropacific.com.au
mribbons
Occasional Contributor
Occasional Contributor
 
Posts: 13
Joined: Mon Sep 01, 2014 12:02 pm

Re: .NET Assembly - Needs Admin permissions to create event

Postby Mike.Sheen » Tue Sep 02, 2014 4:09 pm

mribbons wrote:The first time I ran my .NET app I get a security exception:

The source was not found, but some or all event logs could not be searched. To create the source, you need permission to read all event logs to make sure that the new source name is unique. Inaccessible logs: Security.
at System.Diagnostics.EventLog.FindSourceRegistration(String source, String machineName, Boolean readOnly, Boolean wantToCreate)
at System.Diagnostics.EventLog.SourceExists(String source, String machineName, Boolean wantToCreate)
at System.Diagnostics.EventLogInternal.VerifyAndCreateSource(String sourceName, String currentMachineName)
at System.Diagnostics.EventLogInternal.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData)
at System.Diagnostics.EventLog.WriteEntry(String source, String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData)
at JiwaFinancials.Jiwa.JiwaApplication.Manager.ReportError(String ErrorMessage, String ErrorModule)
at JiwaFinancials.Jiwa.JiwaApplication.Plugin.PluginCollection.Compile()
at JiwaFinancials.Jiwa.JiwaApplication.Manager.Logon(String ServerName, String DatabaseName, AuthenticationModes AuthenticationMode, String JiwaUserName, String JiwaPassword)

It looks like it needs to create the JiwaApplication event source - Can this be done as part of the installation?


Ok, we'll look into that. It's odd that the Jiwa application doesn't exhibit this problem... What folder are you running your application in? Was the application installed, or just run from compiled output?

mribbons wrote:Further to this, every time I run a lot of events like this are created:

"Plugin Manual Serial Numbers encountered an exception when compiling or loading, and was not loaded.

The error was : The 'ReferencedAssemblies' property cannot contain null or empty strings.
Parameter name: options"

Other than this my Manager.Instance.Logon() call seems to work.


Can you load the Plugin Maintenance form in Jiwa, and then navigate to the "Manual Serial Numbers" plugin and note on the references tab which assemblies are not resolved?

Thanks,

Mike
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2440
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 755

Re: .NET Assembly - Needs Admin permissions to create event

Postby mribbons » Tue Sep 02, 2014 4:28 pm

Mike.Sheen wrote:Ok, we'll look into that. It's odd that the Jiwa application doesn't exhibit this problem... What folder are you running your application in? Was the application installed, or just run from compiled output?


It was just compiled.

Mike.Sheen wrote:Can you load the Plugin Maintenance form in Jiwa, and then navigate to the "Manual Serial Numbers" plugin and note on the references tab which assemblies are not resolved?



All assemblies are resolved under Plugin Maintenance for that plugin.

If I copy c:\Program Files (x86)\Jiwa Financials\Jiwa 7\*.dll into my bin\Debug folder the event logs are no longer created so it would seem that the plugins aren't finding the Jiwa DLLs.

Am I doing something wrong? Is there an assumption about where external assemblies should run from?

EDIT: Also, are the Jiwa assemblies installed to the GAC? That might make things a bit faster when compiling the plugins.

I should mention that I still have Jiwa 6 installed, I hope this won't cause any conflicts.
Regards,
Mike Ribbons
Micro Pacific Pty Ltd
http://www.micropacific.com.au
mribbons
Occasional Contributor
Occasional Contributor
 
Posts: 13
Joined: Mon Sep 01, 2014 12:02 pm

Re: .NET Assembly - Needs Admin permissions to create event

Postby Mike.Sheen » Tue Sep 02, 2014 4:35 pm

mribbons wrote:If I copy c:\Program Files (x86)\Jiwa Financials\Jiwa 7\*.dll into my bin\Debug folder the event logs are no longer created so it would seem that the plugins aren't finding the Jiwa DLLs.

Am I doing something wrong? Is there an assumption about where external assemblies should run from?


That does seem to be the problem. The Application Manager will compile the plugins at login time, and the references will be sought after in the GAC and then the folder of the host process (your application). We don't put anything in the GAC, so those assemblies will need to be in the same folder as where your application was launched.

Maybe you could consider referencing all the Jiwa assemblies (jiwa*.dll) in your application and setting Copy Local to true on the references.

Mike
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2440
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 755

Re: .NET Assembly - Needs Admin permissions to create event

Postby mribbons » Tue Sep 02, 2014 4:46 pm

Mike.Sheen wrote:The Application Manager will compile the plugins at login time


This is a significant shift from how things work in Jiwa 6.

Am I right in thinking that the plugins have to always be loaded so they can run their business logic when external applications create orders etc?

Is it possible to only compile the plugins if the binaries are out of date? This is something we do with our scripting engine at Micro Pacific.

This still doesn't solve the problem of needing to ship all of the Jiwa DLLs alongside my scripts though.

Are you willing to consider installing to the GAC?

Also can I expect all these plugins to be enabled? I'm only working with the demo setup at present. I might have to consult my Jiwa consultant.
Regards,
Mike Ribbons
Micro Pacific Pty Ltd
http://www.micropacific.com.au
mribbons
Occasional Contributor
Occasional Contributor
 
Posts: 13
Joined: Mon Sep 01, 2014 12:02 pm

Re: .NET Assembly - Needs Admin permissions to create event

Postby Mike.Sheen » Tue Sep 02, 2014 5:18 pm

mribbons wrote:This is a significant shift from how things work in Jiwa 6.

Quite a few things changed between version 6 and 7.

mribbons wrote:Am I right in thinking that the plugins have to always be loaded so they can run their business logic when external applications create orders etc?

Correct.

mribbons wrote:Is it possible to only compile the plugins if the binaries are out of date? This is something we do with our scripting engine at Micro Pacific.

That is what was always intended - we have a FileHash stored in the database and we compare that against the locally compiled plugin assembly - there was a bug in that implementation and it was fixed recently.

mribbons wrote:This still doesn't solve the problem of needing to ship all of the Jiwa DLLs alongside my scripts though.

I'm not understanding why you consider that a problem, it's a fairly common practice to deploy the assemblies you depend on along with your application.

mribbons wrote:Are you willing to consider installing to the GAC?

We would need to examine that carefully, as side-by-side installs of multiple versions may encounter issues - so the short-term answer is no.

mribbons wrote:Also can I expect all these plugins to be enabled? I'm only working with the demo setup at present. I might have to consult my Jiwa consultant.

You should expect any number of plugins to be enabled.

Mike
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2440
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 755

Re: .NET Assembly - Needs Admin permissions to create event

Postby mribbons » Tue Sep 02, 2014 5:41 pm

Mike.Sheen wrote:I'm not understanding why you consider that a problem, it's a fairly common practice to deploy the assemblies you depend on along with your application.


Normally we would only ship the DLLs containing interfaces and functionality directly referenced by our application as you have seemed to suggest in this post http://forums.jiwa.com.au/viewtopic.php?f=27&t=172

Think about an application that generates Excel documents - Microsoft probably wouldn't be happy if we shipped the whole of Office with our application, and it wouldn't leave much room on the DVD.

In the current Jiwa version there are 140mb of DLLs.

Mike.Sheen wrote:We would need to examine that carefully, as side-by-side installs of multiple versions may encounter issues - so the short-term answer is no.

Agree. This might be handled automatically by .NET versioning.

I'll end up making a deploy configuration to ignore the Jiwa DLLs when making an install package, then copy them across on site.

I tried setting CurrentDirectory to program files\jiwa but the plugin compiles still didn't work - Am I right in assuming that when compiling the plugins Jiwa looks in the executing assemblies folder? Maybe you could allow the caller to set a references folder or look in the registry for the Jiwa.exe location and get the references from there?

On a side note, are you concerned that an external application could break a plugin by having just enough DLLs to say create an order, but not enough to satisfy the plugin?

Would it be better to fail the login under these circumstances?

Also back to the original post would you agree that it's Jiwa's responsibility to set up the JiwaApplication event source? Our application runs as a service under restricted credentials and our staff don't even generally have admin access on the server in question.

Apologies for the rambling post. On a positive note I think I'm fairly close to having my code working with Jiwa 7.
Regards,
Mike Ribbons
Micro Pacific Pty Ltd
http://www.micropacific.com.au
mribbons
Occasional Contributor
Occasional Contributor
 
Posts: 13
Joined: Mon Sep 01, 2014 12:02 pm

Re: .NET Assembly - Needs Admin permissions to create event

Postby Mike.Sheen » Tue Sep 02, 2014 6:05 pm

mribbons wrote:Normally we would only ship the DLLs containing interfaces and functionality directly referenced by our application as you have seemed to suggest in this post http://forums.jiwa.com.au/viewtopic.php?f=27&t=172

Thanks - I shall correct that post to mention that plugins potentially reference any Jiwa assembly and should be referenced with Copy Local set to true.

mribbons wrote:Think about an application that generates Excel documents - Microsoft probably wouldn't be happy if we shipped the whole of Office with our application, and it wouldn't leave much room on the DVD.

We're happy for you to ship our DLL's with your application.

mribbons wrote:In the current Jiwa version there are 140mb of DLLs.

106MB in 7.00.79.00

mribbons wrote:I tried setting CurrentDirectory to program files\jiwa but the plugin compiles still didn't work - Am I right in assuming that when compiling the plugins Jiwa looks in the executing assemblies folder? Maybe you could allow the caller to set a references folder or look in the registry for the Jiwa.exe location and get the references from there?

Correct - we have a custom assembly resolver for the plugin to look in the executing assemblies folder, despite the plugin being compiled to a folder of the ProgramData folder

mribbons wrote:On a side note, are you concerned that an external application could break a plugin by having just enough DLLs to say create an order, but not enough to satisfy the plugin?

Not really, the work-around is as described earlier - make sure the required assemblies are in the same folder as the executing assembly. In many cases external applications probably don't want or care if plugins are run or not anyway.

mribbons wrote:Would it be better to fail the login under these circumstances?

Each plugin can decide how it's failure will be handled using the Exception Policy property of the plugin - it can be Abort, Ignore or Report. Abort will cause login to fail. Whether or not a plugin failing to compile or load should cause a login to fail needs to be per plugin and per site. After your topic was created I note the exception policy to report or abort incorrectly throws a messagebox - I've logged that as bug 10956

mribbons wrote:Also back to the original post would you agree that it's Jiwa's responsibility to set up the JiwaApplication event source? Our application runs as a service under restricted credentials and our staff don't even generally have admin access on the server in question.

Yes, we're looking at doing that as part of the installation. No bug has been logged yet as we need to reproduce it in a test environment here first.

mribbons wrote:Apologies for the rambling post. On a positive note I think I'm fairly close to having my code working with Jiwa 7.


No worries - and that's great news.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2440
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 755

Re: .NET Assembly - Needs Admin permissions to create event

Postby mribbons » Wed Sep 03, 2014 12:12 pm

OK, please mark as answered.

I will follow up on the Event Log issue in a week or so.
Regards,
Mike Ribbons
Micro Pacific Pty Ltd
http://www.micropacific.com.au
mribbons
Occasional Contributor
Occasional Contributor
 
Posts: 13
Joined: Mon Sep 01, 2014 12:02 pm

Re: .NET Assembly - Needs Admin permissions to create event   Topic is solved

Postby Scott.Pearce » Mon Sep 15, 2014 4:33 pm

FYI. The event log issue has now been addressed via bug 10983.
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 742
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 221


Return to Technical and or Programming

Who is online

Users browsing this forum: Google [Bot] and 3 guests

cron