Closed CSharpDummy closed 7 years ago
Hi!
The 'System.ExecutionEngineException' (80131506) is pretty general and can be caused by many things. It is impossible to say more about it without detailed information.
Could you explain your environment? What version of .NET is installed on you PC? Wich OPC-server do you use? Have you installed Opc Core Components (https://opcfoundation.org/developer-tools/developer-kits-classic/core-components)?
Also, give us a little bit more code, please.
The code is pretty much from your example (see below) I use also the Matrikon Test server. I did install the OPC core components. I compiled the project under Net 4.52
class Program
{
private const string ServerUri = "Matrikon.OPC.Simulation.1"; //ProgId for matrikon simulation server
private const string SubscribeItemId = "Random.Int4"; //itemId for subscribed opc item
private const string GroupName = "TestGroup"; //group name for make subscription
private const int UpdateRateInMilliseconds = 1000; //subscription update rate for group
[MTAThread]
static void Main(string[] args)
{
Uri url = UrlBuilder.Build("Matrikon.OPC.Simulation.1");
using (var server = new OpcDaServer(url))
{
// Connect to the server first.
server.Connect();
// Browse elements.
var browser = new OpcDaBrowserAuto(server);
BrowseChildren(browser);
}
}
private static void BrowseChildren(IOpcDaBrowser browser, string itemId = null, int indent = 0)
{
// Browse elements.
// When itemId is null, root elements will be browsed.
OpcDaBrowseElement[] elements = browser.GetElements(itemId);
// Output elements.
foreach (OpcDaBrowseElement element in elements)
{
// Output the element.
Console.Write(new String(' ', indent));
Console.WriteLine(element);
// Skip elements without children.
if (!element.HasChildren)
continue;
// Output children of the element.
BrowseChildren(browser, element.ItemId, indent + 2);
}
}
Hm. I have tried with you code and it works. I tried with simplified one:
static void Main()
{
Uri url = UrlBuilder.Build("Matrikon.OPC.Simulation.1");
using (var server = new OpcDaServer(url))
{
server.Connect();
var browser = new OpcDaBrowserAuto(server);
OpcDaBrowseElement[] elements = browser.GetElements("Bucket Brigade");
OpcDaBrowseElement element = elements.First(i => i.ItemId == "Bucket Brigade.Int4");
Console.WriteLine(element);
Console.ReadLine();
}
}
Things you can try:
Hi, I am facing the same issue while browsing the element,
I am using .Net Core 3.1 framework and installed TitaniumAS.Opc.Client.NetCore NuGet package for the same. i also installed Opc Core Components.
Even when i passed null input to GetElements method, i am facing this exception
i am using this method to browser channel list from server, the exception is not showing when we pass any string like "Bucket Brigade" or directly server name. but we are not getting any channel list or element, its giving empty output.
My code fails here:
OpcDaBrowseElement[] elements = browser.GetElements(itemId);
not much info ..
FatalExecutionEngineError occurred HResult=-2146233082 Message=Exception of type 'System.ExecutionEngineException' was thrown. InnerException: