hoseman Posted March 3, 2016 Report Share Posted March 3, 2016 I am using the demo ComDriver code as follows: using System; using Unitronics.ComDriver; namespace Com_Drive_Net___Example { class AccessClass { static PLC plc; public static void Test (){ Ethernet eth = new Ethernet ("192.168.1.152", 20256, EthProtocol.TCP, 3, 3000); try{ plc = PLCFactory.GetPLC(eth, 0); plc.EventAbortCompleted+=new PLC.AbortCompletedDelegate(plc_EventAbortCompleted); }catch(Exception e){ eth.Disconnect(); Console.WriteLine ("Error1:"+e.Message+"-->("+e.TargetSite+")"+e.StackTrace+"-->"+e.Source); } try{ Console.WriteLine(plc.Version.OPLCModel); Console.WriteLine (plc.PlcName); Console.WriteLine(eth.Connected); Console.WriteLine(plc.UnitId); }catch(Exception e){ eth.Disconnect(); Console.WriteLine ("Error2:"+e.Message+"-->("+e.TargetSite+")"+e.StackTrace); } Console.Read (); } public static void plc_EventAbortCompleted(){ Console.WriteLine ("dunno"); } } } It is pretty much straight out of the book. I continue to get the following error: Unhandled Exception: Unitronics.ComDriver.ComDriveExceptions: Cannot communicate with the PLC with the specified UnitID! at Unitronics.ComDriver.PLC..ctor (Int32 unitId, Unitronics.ComDriver.Channel channel, Boolean suppressEthernetHeader) [0x00000] in <filename unknown>:0 at Unitronics.ComDriver.PLCFactory.getPLC (Unitronics.ComDriver.Channel& channel, Int32 unitId, System.Boolean& isConnected, Boolean suppressEthernetHeader) [0x00000] in <filename unknown>:0 [ERROR] FATAL UNHANDLED EXCEPTION: Unitronics.ComDriver.ComDriveExceptions: Cannot communicate with the PLC with the specified UnitID! at Unitronics.ComDriver.PLC..ctor (Int32 unitId, Unitronics.ComDriver.Channel channel, Boolean suppressEthernetHeader) [0x00000] in <filename unknown>:0 at Unitronics.ComDriver.PLCFactory.getPLC (Unitronics.ComDriver.Channel& channel, Int32 unitId, System.Boolean& isConnected, Boolean suppressEthernetHeader) [0x00000] in <filename unknown>:0 I have tried three different versions of Unitronics.ComDriver.dll, dated 7/26/15, 7/29/15 and compiled myself yesterday, 3/2/16. Same error on everyone. I am not a C# expert by no means, but I can't see what I might be doing wrong. We set the the PLC to TCP/slave and set its Socket 0 Port to 20256 (mostly in desperation) I'm not sure what to try next? Thanks Link to comment Share on other sites More sharing options...
Saragani Posted March 6, 2016 Report Share Posted March 6, 2016 Hi, this could also be a UAC / Permission issues, since the communication dll is trying to extract an xml file. You could make the dll not extract the dll, and use it in RAM, by: PLCFactory.WorkWithXmlInternally = true; (Do this just once, when the application starts). Tell me if it helps. If not, when you can debug the code (the exception you see hides the actual error. I don't know if it fails dues to timeout or some other issues). Link to comment Share on other sites More sharing options...
yakut-soft Posted November 28, 2016 Report Share Posted November 28, 2016 Hi, I tried to use ComDriver .dll, but i get "Unknown PLC Model" can you help me about this (the plc model is V700). Link to comment Share on other sites More sharing options...
Saragani Posted November 28, 2016 Report Share Posted November 28, 2016 You must be using an old version of the DLL. Which version are you using? Link to comment Share on other sites More sharing options...
yakut-soft Posted November 28, 2016 Report Share Posted November 28, 2016 i don't know which version, i doawnload from this link: http://forum.unitronics.com/applications/core/interface/file/attachment.php?id=1148 can you share new version with me? Link to comment Share on other sites More sharing options...
Saragani Posted November 28, 2016 Report Share Posted November 28, 2016 It is 2 years old. Just go to Unitronicsplc.com, and on the top toolbar click on Software -> Visilogic Under programming tools for developers, you should find .Net Driver, which is a version from last year. I should be enough Link to comment Share on other sites More sharing options...
yakut-soft Posted November 28, 2016 Report Share Posted November 28, 2016 Thank you, it has been working correctly now Link to comment Share on other sites More sharing options...
MVP 2023 Joe Tauser Posted March 2, 2017 MVP 2023 Report Share Posted March 2, 2017 I got a call today from a customer having this problem after moving his program to Windows 10. He is using 1.0.0.67 of the .NET driver. What shall we try? Joe T. Link to comment Share on other sites More sharing options...
bwdavis Posted March 2, 2017 Report Share Posted March 2, 2017 Hi, I'm trying to communicate with a unitronics plc and am using the C# sample code provided by an email from Unitronics, Boston Support as below: Link to comment Share on other sites More sharing options...
Saragani Posted March 2, 2017 Report Share Posted March 2, 2017 32 minutes ago, Joe Tauser said: I got a call today from a customer having this problem after moving his program to Windows 10. He is using 1.0.0.67 of the .NET driver. What shall we try? Joe T. Run the program as administrator. There is also a property called PLCFactory.WorkWithXMLInternally (or something similar), which if set to true, the .net driver will not try to extract the xml to the drive (which results an access denied, and an error which makes the driver think that there is a communication problem). 7 minutes ago, bwdavis said: Hi, I'm trying to communicate with a unitronics plc and am using the C# sample code provided by an email from Unitronics, Boston Support as below: I have not seen your code. Try running your code as administrator. Link to comment Share on other sites More sharing options...
bwdavis Posted March 2, 2017 Report Share Posted March 2, 2017 2 minutes ago, Saragani said: Run the program as administrator. There is also a property called PLCFactory.WorkWithXMLInternally (or something similar), which if set to true, the .net driver will not try to extract the xml to the drive (which results an access denied, and an error which makes the driver think that there is a communication problem). Sorry, I posted that prematurely. New on the forum and all that. I did try PLCFactory.WorkWithXMLInternally = true; I placed the code directly above the commented line at the top of the try block below. It made no difference. I will try your suggestions. Hi, I'm trying to communicate with a unitronics plc and am using the C# sample code provided by an email from Unitronics, Boston Support as below: private void Connect_Click(object sender, EventArgs e) { Ethernet ethernet = new Ethernet("10.10.11.25", 20256, EthProtocol.TCP, 3, 3000); try { // plc = PLCFactory.GetPLC(ethernet, 0); // <-- No overload for method 'GetPLC' takes '2' arguments plc = PLCFactory.GetPLC(ethernet, 0, true); // <-- Add boolean so it will build plc.EventAbortCompleted += new PLC.AbortCompletedDelegate(plc_EventAbortCompleted); setButtonsEnableState(true); PlcVersion version = plc.Version; txtModel.Text = version.OPLCModel; txtHW.Text = version.HWVersion; txtOS.Text = version.OSVersion; txtBoot.Text = version.Boot; txtBinLib.Text = version.BinLib; txtFactoryBoot.Text = version.FactoryBoot; try { txtPlcName.Text = plc.PlcName; } catch { } } catch (Exception m) { MessageBox.Show(m.Message); setButtonsEnableState(false); ethernet.Disconnect(); System.Windows.Forms.MessageBox.Show("Could not establish a connection to the PLC"); } } This code is straight from the sample code provided with latest Unicom.CommDriver.dll. Trying to build this on VS 2008 C#, I first get: No overload for method 'GetPLC' takes 2 arguments Editing that, and adding a boolean, true or false so that it will build, and then running it, I get: Cannot communicate with the PLC with the specified UnitID! Tried running in compatibility mode as administrator for Windows XP SP3, same result. Application code broke with upgrade to windows 10. Environment Windows 10 build 1607 Visual Studio 9.0 (2008) C#.NET Bruce D I have not seen your code. Try running your code as administrator. Link to comment Share on other sites More sharing options...
Saragani Posted March 3, 2017 Report Share Posted March 3, 2017 Well, if you have a newer version of Visual Studio, then you can pass only 2 arguments to the PLCFactory.GetPLC (due to the added support of optional parameters) For having this code work on Windows 10, you will need to add PLCFactory.WorkWithXmlInternally = true; For example: private void Connect_Click(object sender, EventArgs e) { PLCFactory.WorkWithXmlInternally = true; Ethernet ethernet = new Ethernet("10.10.11.25", 20256, EthProtocol.TCP, 3, 3000); try { // plc = PLCFactory.GetPLC(ethernet, 0); // <-- No overload for method 'GetPLC' takes '2' arguments plc = PLCFactory.GetPLC(ethernet, 0, true); // <-- Add boolean so it will build plc.EventAbortCompleted += new PLC.AbortCompletedDelegate(plc_EventAbortCompleted); setButtonsEnableState(true); PlcVersion version = plc.Version; txtModel.Text = version.OPLCModel; txtHW.Text = version.HWVersion; txtOS.Text = version.OSVersion; txtBoot.Text = version.Boot; txtBinLib.Text = version.BinLib; txtFactoryBoot.Text = version.FactoryBoot; try { txtPlcName.Text = plc.PlcName; } catch { } } catch (Exception m) { MessageBox.Show(m.Message); setButtonsEnableState(false); ethernet.Disconnect(); System.Windows.Forms.MessageBox.Show("Could not establish a connection to the PLC"); } } This property can be set only once (so you can set it on the program load, instead of setting true on every button click, but I wrote it here just for the example). Link to comment Share on other sites More sharing options...
bwdavis Posted March 7, 2017 Report Share Posted March 7, 2017 I will try this when I return to my office March 8th and let you know. Thank you for your help. Bruce Link to comment Share on other sites More sharing options...
bwdavis Posted March 8, 2017 Report Share Posted March 8, 2017 Saragani, The suggestion you gave worked perfectly. It is important to note that the setting of PLCFactory.WorkWithXmlInternally = true MUST happen prior to the call to GetPLC. I had tried setting it inside the try block with no success, but as it appears below, it works perfectly on Windows 10 build 1607. Many thanks for your attention. Kind Regards Bruce private void Connect_Click(object sender, EventArgs e) { PLCFactory.WorkWithXmlInternally = true; Ethernet ethernet = new Ethernet("10.10.11.25", 20256, EthProtocol.TCP, 3, 3000); try { plc = PLCFactory.GetPLC(ethernet, 0); // <-- Add boolean so it will build plc.EventAbortCompleted += new PLC.AbortCompletedDelegate(plc_EventAbortCompleted); setButtonsEnableState(true); PlcVersion version = plc.Version; txtModel.Text = version.OPLCModel; txtHW.Text = version.HWVersion; txtOS.Text = version.OSVersion; txtBoot.Text = version.Boot; txtBinLib.Text = version.BinLib; txtFactoryBoot.Text = version.FactoryBoot; try { txtPlcName.Text = plc.PlcName; } catch { } } catch (Exception m) { MessageBox.Show(m.Message); setButtonsEnableState(false); ethernet.Disconnect(); System.Windows.Forms.MessageBox.Show("Could not establish a connection to the PLC"); } } Link to comment Share on other sites More sharing options...
Camilla Posted August 22, 2018 Report Share Posted August 22, 2018 On 3/6/2016 at 7:18 AM, Saragani said: Hi, this could also be a UAC / Permission issues, since the communication dll is trying to extract an xml file. You could make the dll not extract the dll, and use it in RAM, by: PLCFactory.WorkWithXmlInternally = true; (Do this just once, when the application starts). Tell me if it helps. If not, when you can debug the code (the exception you see hides the actual error. I don't know if it fails dues to timeout or some other issues). I have this problem. i show that my problem is a timeout. In this case what i do? thanks Link to comment Share on other sites More sharing options...
Saragani Posted August 23, 2018 Report Share Posted August 23, 2018 Try to communicate with VisiLogic and see if it manages to communicate. Maybe the IP or port is incorrect, or the port if not forwarded, or a firewall blocks the communication. Link to comment Share on other sites More sharing options...
René Kapitein Posted May 20, 2021 Report Share Posted May 20, 2021 On 3/6/2016 at 7:18 AM, Saragani said: PLCFactory.WorkWithXmlInternally = true This worked for me also Link to comment Share on other sites More sharing options...
Oath Posted August 16 Report Share Posted August 16 I should've Googled this issue about a week ago! I was working on an unrelated portion of a program we use, and when I went to test the change, the program stopped being able to talk to our PLC! After much fiddling with it in my spare time, I decided I'd look into why it might not communicate, and this was the solve. I *am* curious as to why the internal XML option isn't the default, though - but regardless, this answer is still solving problems here in 2024. Link to comment Share on other sites More sharing options...
Saragani Posted August 22 Report Share Posted August 22 The XML is extracted, so you can also alter it if needed, for adding support for new PLC models (If you are using an older version). The new ComDriver that comes with the latest Remote Operator (as dll), also comes with a Unitronics.Comdriver.Security.dll, since latest firmwares support password protection on Ethernet communication, and as far as I remember, the XML is now extracted to Local AppData, so the UAC does not affect it anymore Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now