Online Forums
Technical support is provided through Support Forums below. Anybody can view them; you need to Register/Login to our site (see links in upper right corner) in order to Post questions. You do not have to be a licensed user of our product.
Please read Rules for forum posts before reporting your issue or asking a question. OPC Labs team is actively monitoring the forums, and replies as soon as possible. Various technical information can also be found in our Knowledge Base. For your convenience, we have also assembled a Frequently Asked Questions page.
Do not use the Contact page for technical issues.
Attempt to add existing key into a dictionary
This is now fixed in the currently posted QuickOPC 2018.1 (on our Web page, and also in the NuGet packages). It is version/build 5.52.91 or later.
Please rebuild your project with it and re-test.
Best regards
Please Log in or Create an account to join the conversation.
Thank you very much for the additional information. It is very helpful. From the call stack, it looks like a bug in QuickOPC. Unfortunately I cannot determine more details until next week when I am back in the office.
Please bear with me and I will respond then.
Best regards
Please Log in or Create an account to join the conversation.
this log shows call stack and log entries
Please Log in or Create an account to join the conversation.
1. The log you have sent contains two suspicious things: One is
The other isAn exception occurred in the OnAfterInstall event handler of System.ServiceProcess.ServiceInstaller.
System.ArgumentException: Attempt to add existing key into a dictionary."
An exception occurred in the OnAfterInstall event handler of System.ServiceProcess.ServiceInstaller.
OpcLabs.EasyOpc.UA.OperationModel.UAException: An OPC-UA operation failure with error code -1 (0xFFFFFFFF) occurred, originating from ''. The inner OPC-UA service exception with service result 'BadCertificateUntrusted' contains details about the problem.
The inner exception OpcLabs.EasyOpc.UA.UAServiceException was thrown with the following error message: Self Signed Certificate is not trusted.
IssuerName: CN=InstallUtil.exe, DC=[HIDDEN AS WELL] = BadCertificateUntrusted.
+ The error occurred while checking the (client) application instance certificate. The certificate generator path was "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Opc.Ua.CertificateGenerator.exe"..
Especially for the first one, it would be really useful to know the call stack (where it is coming from). Can you put try/catch block around the call to EasyUAClient.Install(), and log the call stack in case of an exception?
2. It would be also good if you can hook to EasyUAClient.LogEntry event before calling EasyUAClient.Install(), and then log all the message it generates.
3. Although what I will describe in this point is not probably causing the issue, it is a problem as well and I suggest that you resolve it. The problem has to do with naming of the generated certificate. If you do not set the name explicitly (more about it later), QuickOPC generates a name automatically, using information such as the running executable's name. The certificate name is used for lookup: When the certificate is generated, and the application is run the next time, it looks for the certificate and tries to reuse it.
In you case, using the automatically-generated certificate name will lead to problems. I can see that although your application's name is OpcToXml.exe, the name of the certificate generated by EasyUAClient.Install() is "InstallUtil.exe" - because that's what the running program at that time is, and "OpcToXml.exe" is just hosted by it. But when you will later run the actual OpcToXml.exe, it will look for "OpcToXml.exe" certificate (or possibly other auto-generated name - but not InstallUtil.exe".
In order to prevent this from happening, set the certificate (application) name explicitly in *both* the installation part, and the normal execution part, *before* calling EasyUAClient.Install() or any other of its methods. The process is described here: opclabs.doc-that.com/files/onlinedocs/QuickOpc/Latest/User%2...%20Instance%20Certificate.html . An example in C# for that looks like this:
Best regards
Please Log in or Create an account to join the conversation.
It's the nuget package version 5.52.75
2) The certificate needs to be installed into the trusted store. Does your customer run the installer under administrator account, *and* with elevated privileges? (the behavior of Windows depends on UAC settings in this respect; your computer may be set differently than customer's).
They are 'running as administrator" - i assume this must mean they are an administrator...
On my PC the certificate ends up in c:\program data\OPC Foundation\CertificateStores\UA Applications\certs - i'll check what they have in there..
3) Is the installer in an executabel separate from the actual application, or are they "in one"?
They are installing the exe I have produced using installutil (in .net 4.5) folder
with...
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe OpcToXml.exe
4) Do you set the ApplicationName parameter in EasyUAClient shared parameters either in the installer project, or in the actual app?
No
Please Log in or Create an account to join the conversation.
I do not know yet what can be causing it, but have some questtions:
1) Which QuickOPC version/build are you using?
2) The certificate needs to be installed into the trusted store. Does your customer run the installer under administrator account, *and* with elevated privileges? (the behavior of Windows depends on UAC settings in this respect; your computer may be set differently than customer's).
3) Is the installer in an executabel separate from the actual application, or are they "in one"?
4) Do you set the ApplicationName parameter in EasyUAClient shared parameters either in the installer project, or in the actual app?
Thank you
Please Log in or Create an account to join the conversation.
this is what he gets in his event log (he has tried from two different directories) + [HIDDEN] and [HIDDEN AS WELL] is text i have replaced for anonimity
````
Installing assembly 'C:\XML Download\02 - Application Directory\OpcToXml.exe'.
Affected parameters are:
logtoconsole =
assemblypath = C:\XML Download\02 - Application Directory\OpcToXml.exe
logfile = C:\XML Download\02 - Application Directory\OpcToXml.InstallLog
Installing service OpcXml...
Creating EventLog source OpcXml in log Application...
An exception occurred in the OnAfterInstall event handler of System.ServiceProcess.ServiceInstaller.
System.ArgumentException: An item with the same key has already been added.
Rolling back assembly 'C:\XML Download\02 - Application Directory\OpcToXml.exe'.
Affected parameters are:
logtoconsole =
assemblypath = C:\XML Download\02 - Application Directory\OpcToXml.exe
logfile = C:\XML Download\02 - Application Directory\OpcToXml.InstallLog
Restoring event log to previous state for source OpcXml.
Installing assembly 'C:\XML Download\02 - Application Directory\OpcToXml.exe'.
Affected parameters are:
logtoconsole =
assemblypath = C:\XML Download\02 - Application Directory\OpcToXml.exe
logfile = C:\XML Download\02 - Application Directory\OpcToXml.InstallLog
Installing service OpcXml...
Creating EventLog source OpcXml in log Application...
An exception occurred in the OnAfterInstall event handler of System.ServiceProcess.ServiceInstaller.
System.ArgumentException: Attempt to add existing key into a dictionary.
Rolling back assembly 'C:\XML Download\02 - Application Directory\OpcToXml.exe'.
Affected parameters are:
logtoconsole =
assemblypath = C:\XML Download\02 - Application Directory\OpcToXml.exe
logfile = C:\XML Download\02 - Application Directory\OpcToXml.InstallLog
Restoring event log to previous state for source OpcXml.
Installing assembly 'C:\XML Download\[HIDDEN]\OpcToXml.exe'.
Affected parameters are:
logtoconsole =
assemblypath = C:\XML Download\[HIDDEN]\OpcToXml.exe
logfile = C:\XML Download\[HIDDEN]\OpcToXml.InstallLog
Installing service OpcXml...
Creating EventLog source OpcXml in log Application...
An exception occurred in the OnAfterInstall event handler of System.ServiceProcess.ServiceInstaller.
System.ArgumentException: Attempt to add existing key into a dictionary.
Rolling back assembly 'C:\XML Download\[HIDDEN]\OpcToXml.exe'.
Affected parameters are:
logtoconsole =
assemblypath = C:\XML Download\[HIDDEN]\OpcToXml.exe
logfile = C:\XML Download\[HIDDEN]\OpcToXml.InstallLog
Restoring event log to previous state for source OpcXml.
Installing assembly 'C:\XML Download\[HIDDEN]\OpcToXml.exe'.
Affected parameters are:
logtoconsole =
assemblypath = C:\XML Download\[HIDDEN]\OpcToXml.exe
logfile = C:\XML Download\[HIDDEN]\OpcToXml.InstallLog
Installing service OpcXml...
Creating EventLog source OpcXml in log Application...
An exception occurred in the OnAfterInstall event handler of System.ServiceProcess.ServiceInstaller.
OpcLabs.EasyOpc.UA.OperationModel.UAException: An OPC-UA operation failure with error code -1 (0xFFFFFFFF) occurred, originating from ''. The inner OPC-UA service exception with service result 'BadCertificateUntrusted' contains details about the problem.
The inner exception OpcLabs.EasyOpc.UA.UAServiceException was thrown with the following error message: Self Signed Certificate is not trusted.
IssuerName: CN=InstallUtil.exe, DC=[HIDDEN AS WELL] = BadCertificateUntrusted.
+ The error occurred while checking the (client) application instance certificate. The certificate generator path was "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Opc.Ua.CertificateGenerator.exe"..
Rolling back assembly 'C:\XML Download\[HIDDEN]\OpcToXml.exe'.
Affected parameters are:
logtoconsole =
assemblypath = C:\XML Download\[HIDDEN]\OpcToXml.exe
logfile = C:\XML Download\[HIDDEN]\OpcToXml.InstallLog
Restoring event log to previous state for source OpcXml.
````
my service installer just has:
Please Log in or Create an account to join the conversation.