Jump to content

Welcome to eMastercam

Register now to participate in the forums, access the download area, buy Mastercam training materials, post processors and more. This message will be removed once you have signed in.

Use your display name or email address to sign in:

Nethook won't run on new computer


Recommended Posts

Both are 64 bit OS - Windows 7

 

The computer that it runs on is - 64 bit Windows 7 Professional (Laptop)

 

The computer that it doesn't run on - 64 bit Windows 7 Professional SP1 (Desktop)

 

Both have version 15.2.1.2

Build date: May 29, 2012

 

In the about in mastercam it says my Nethook2_0.dll for both installs: version 0.0.0.0

Link to comment
Share on other sites

So it looks like i was using .net 4.0 framework instead of 3.5.

 

This all this nethook does is launch an external program so it does not use any forms.

 

I switched it to 3.5 and now for some reason it won't compile, give me errors.

 

attached is a pic of the errors i get now

 

here's my code:

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using Mastercam.App;
using Mastercam.App.Types;
namespace Program_Run_Nethook
{
#region class NETHOOK
public class Program_Run_Nethook : NetHook2App
{
 public override MCamReturn Run(int param)
 {
	 bool ret = true; // Assume succcess 
	 MessageBox.Show("your in!");
	 System.Diagnostics.Process.Start(@"Z:\Mastercam X6 Files\Machines\Mazak 510C-II\Tool Sequencer.exe");
	 return (ret ? MCamReturn.NoErrors : MCamReturn.ErrorOccurred);
 }
}
#endregion class NETHOOK
}

not sure whats wrong here.

 

thanks for all the help so far!

post-38000-0-09999500-1378391991_thumb.png

Link to comment
Share on other sites

For X7 you do want the NET Framework v4.0, as that is the version that the NETHook2 (and NETHook3) that shipped with X7 targets.

So Visual Studio was correct in telling you that - "You're doing something wrong".

 

Even though Mastercam can be 32-bit or 64-bit, we're working in .NET here and...

We can build our NETHook AddOn using the "AnyCPU" platform.

This way the (.NET) DLL we generate can be used for either 32-bit or 64-bit Mastercam.

If you do the use the "AnyCPU" platform, you will see this warning when you build your project ->

 

Warning - There was a mismatch between the processor architecture of the project being built "MSIL"

and the processor architecture of the reference "NETHook2_0", "AMD64".

blah, blah blah...

 

If your NETHook project only references Mastercam's NETHook2_0.DLL (or NETHook3_0.DLL) you can safely ignore this warning.

If this warning really bothers you, there is a way to (manually) add a line in the .csproj (project) file that will tell Visual Studio to stop complaining about this.

 

I just built and ran this code using 64-bit Mastercam X7 (SP2) ->

*I added some input validity checking so that it won't throw an Exception just because the file doesn't exist.*

The only way I can get the "Unknown File Type" error (using this code) is if I build the project using the "X86" platform.

If I buld it using "AnyCPU" or "X64", it runs fine*.

"Fine" in that I see the error message telling me that the EXE file doesn't exist on my system. ;)

using System.Windows.Forms;
using Mastercam.App;
using Mastercam.App.Types;

namespace Program_Run_Nethook
{
#region class NETHOOK

public class Program_Run_Nethook : NetHook2App
{
public override MCamReturn Run(int param)
{
bool ret = true; // Assume success 
MessageBox.Show("your in!");

const string exe = @"Z:\Mastercam X6 Files\Machines\Mazak 510C-II\Tool Sequencer.exe";
if (System.IO.File.Exists(exe))
{
System.Diagnostics.Process.Start(exe);
}
else
{
MessageBox.Show("File to execute was not found! ->\n" + exe, "ERROR!",
MessageBoxButtons.OK, MessageBoxIcon.Error);
ret = false;
}

return (ret ? MCamReturn.NoErrors : MCamReturn.ErrorOccurred);
}
}

#endregion class NETHOOK
}

Link to comment
Share on other sites
I'm building this for X6

X6/X7 is the same in regards to the .NET Framework requirements.

*And you don't have the newer NETHook3 in X6.

 

Works fine on one system still,but same error on the other

Hmmmm....

Not something I'd usually go for, but maybe the v4.0 Framework is "messed up" (that's the technical term) on the non-working system?

Maybe try uninstalling / re-installing the v4 .NET Framework on the "bad" system.

Link to comment
Share on other sites
  • 4 weeks later...

X6/X7 is the same in regards to the .NET Framework requirements.

*And you don't have the newer NETHook3 in X6.

 

Maybe this post should be another topic - but is the NETHook2_0.dll that comes with X7 usuable in X6?

I see more functionality in that version ...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.

Join us!

eMastercam - your online source for all things Mastercam.

Together, we are the strongest Mastercam community on the web with over 56,000 members, and our online store offers a wide selection of training materials for all applications and skill levels.

Follow us

×
×
  • Create New...