You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are using MTConnect.NET 6.5.0. We deploy our application as a single file executable.
Given this context Assmbly.Get() method found in MTConnect.NET uses Assebly.Location to find all dll files. But, in single file dployments Assembly.Location returns empty and actually all dll files are compressed and embedded inside the single file executable.
Current workaround for us was to create a static class and add document formatters to ResponseDocumentFormatter private static fields using reflection.
publicstaticclassMtConnectRuntime{publicstaticvoidInitialize(){SetMtConnectResponseDocumentFormatters();}privatestaticvoidSetMtConnectResponseDocumentFormatters(){// [AÖ] This is needed beacuse when deployment is selected SingleFile Assemblies.Get() (found in MTConnect.NET lib) can not inspect assemblies// See: https://learn.microsoft.com/en-us/dotnet/core/deploying/single-file/warnings/il3000// See: https://learn.microsoft.com/en-us/dotnet/core/deploying/single-file/overview?tabs=clitry{varfields=typeof(ResponseDocumentFormatter).GetFields(BindingFlags.NonPublic|BindingFlags.Static);var_firstRead=fields.FirstOrDefault(x =>x.Name=="_firstRead");var_formatters=fields.FirstOrDefault(x =>x.Name=="_formatters");if(_firstRead!=null){_firstRead.SetValue(null,false);}if(_formatters!=null){varformatters=(ConcurrentDictionary<string,IResponseDocumentFormatter>)_formatters.GetValue(null);formatters.Clear();varxml=newXmlResponseDocumentFormatter();formatters.TryAdd(xml.Id.ToLower(),xml);varjson=newJsonResponseDocumentFormatter();formatters.TryAdd(json.Id.ToLower(),json);varhtml=newJsonHttpResponseDocumentFormatter();formatters.TryAdd(html.Id.ToLower(),html);varmqtt=newJsonMqttResponseDocumentFormatter();formatters.TryAdd(mqtt.Id.ToLower(),mqtt);}}catch(Exceptionex){Console.WriteLine($"{nameof(MtConnectRuntime.SetMtConnectResponseDocumentFormatters)}{ex.ToErrorMessage()}\r\n{ex.StackTrace}");}}}
The text was updated successfully, but these errors were encountered:
Hi,
We are using MTConnect.NET 6.5.0. We deploy our application as a single file executable.
Given this context Assmbly.Get() method found in MTConnect.NET uses Assebly.Location to find all dll files. But, in single file dployments Assembly.Location returns empty and actually all dll files are compressed and embedded inside the single file executable.
Current workaround for us was to create a static class and add document formatters to ResponseDocumentFormatter private static fields using reflection.
The text was updated successfully, but these errors were encountered: