By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,249 Members | 1,853 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,249 IT Pros & Developers. It's quick & easy.

Using a .NET component in VFP

P: n/a
Hi All,

I've been working on building a .dll in C# (framework 1.1) and using it in
VFP8. As always, the example that runs so smoothly in the article fails at
a rather basic point in practice. When attempting to create the object,

After building a dll, I used RegAsm.exe to register and received "Types
registered successfully" message. But upon trying to create the object in
VFP, I get the error:

OLE error code 0x80070002: The system cannot find the file specified.

Anyone have an idea what (probably basic) thing I'm missing here?

TIA,

John
Nov 15 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
In article <ed*************@TK2MSFTNGP11.phx.gbl>, js******@c-comld.com
says...
Hi All,

I've been working on building a .dll in C# (framework 1.1) and using it in
VFP8. As always, the example that runs so smoothly in the article fails at
a rather basic point in practice. When attempting to create the object,

After building a dll, I used RegAsm.exe to register and received "Types
registered successfully" message. But upon trying to create the object in
VFP, I get the error:

OLE error code 0x80070002: The system cannot find the file specified.

Anyone have an idea what (probably basic) thing I'm missing here?


Usually, .NET assemblies reside in the same directory as the executable
(even with COM-interop). I've had this happen before when doing stuff
inside the VB6 IDE. I had to place the .NET assembly in the same
directory as the IDE (VB6.EXE). Perhaps VFP needs this to.

--
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net/psteele
Nov 15 '05 #2

P: n/a
Thanks, Patrick. I'll start playing around with that idea. Here's an
oddity I have yet to figure out...

I got it to work (instantiates in VFP and works as expected). By doing the
following steps:

1. Generated a strong name using sn.exe;
2. Added attributes to the cs file for reflection to identify a version and
use the strong name;
3. Built the DLL using the /define:STRONG switch; and
4. Ran GACUtil to load into the GAC.

I've tried the same process with another .cs file in the same folder, yet it
continues to give the same error. If it helps, here are the starts of both
files:

//This worked:
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.ComponentModel;
using System.Runtime.InteropServices;

#if STRONG
[assembly: System.Reflection.AssemblyVersion("1.0.0.0")]
[assembly: System.Reflection.AssemblyKeyFile("DotNet.snk")]
#endif

namespace DotNetCOM
{
[ClassInterface(ClassInterfaceType.AutoDual)]
[ProgId("DotNetCOM.wwImaging")]
public class wwImaging : Component
{...}
}
//This builds and adds to the cache but still gives same error (cannot find
the file):
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Text;

#if STRONG
[assembly: System.Reflection.AssemblyVersion("1.0.0.0")]
[assembly: System.Reflection.AssemblyKeyFile("Calculator.snk" )]
#endif

namespace Mathematics
{
[ClassInterface(ClassInterfaceType.AutoDual)]
[ProgId("Mathematics.Calculator")]
public class Calculator : Component
{...}
}

Thanks again,

John

"Patrick Steele [MVP]" <pa*****@mvps.org> wrote in message
news:MP************************@msnews.microsoft.c om...
In article <ed*************@TK2MSFTNGP11.phx.gbl>, js******@c-comld.com
says...
Hi All,

I've been working on building a .dll in C# (framework 1.1) and using it in VFP8. As always, the example that runs so smoothly in the article fails at a rather basic point in practice. When attempting to create the object,

After building a dll, I used RegAsm.exe to register and received "Types
registered successfully" message. But upon trying to create the object in VFP, I get the error:

OLE error code 0x80070002: The system cannot find the file specified.

Anyone have an idea what (probably basic) thing I'm missing here?


Usually, .NET assemblies reside in the same directory as the executable
(even with COM-interop). I've had this happen before when doing stuff
inside the VB6 IDE. I had to place the .NET assembly in the same
directory as the IDE (VB6.EXE). Perhaps VFP needs this to.

--
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net/psteele

Nov 15 '05 #3

P: n/a
One more piece and I think I've got it!

In previous attempts, it appears that a type library had been built and
registered for the one that was working. For the other, I can't recall if I
had built one. However, once I did, it too worked. It seems if I add step
3.5: Build and register tlb file with RegAsm; it comes together!
"John Spiegel" <js******@c-comld.com> wrote in message
news:eZ**************@TK2MSFTNGP10.phx.gbl...
Thanks, Patrick. I'll start playing around with that idea. Here's an
oddity I have yet to figure out...

I got it to work (instantiates in VFP and works as expected). By doing the following steps:

1. Generated a strong name using sn.exe;
2. Added attributes to the cs file for reflection to identify a version and use the strong name;
3. Built the DLL using the /define:STRONG switch; and
4. Ran GACUtil to load into the GAC.

I've tried the same process with another .cs file in the same folder, yet it continues to give the same error. If it helps, here are the starts of both files:

//This worked:
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.ComponentModel;
using System.Runtime.InteropServices;

#if STRONG
[assembly: System.Reflection.AssemblyVersion("1.0.0.0")]
[assembly: System.Reflection.AssemblyKeyFile("DotNet.snk")]
#endif

namespace DotNetCOM
{
[ClassInterface(ClassInterfaceType.AutoDual)]
[ProgId("DotNetCOM.wwImaging")]
public class wwImaging : Component
{...}
}
//This builds and adds to the cache but still gives same error (cannot find the file):
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Text;

#if STRONG
[assembly: System.Reflection.AssemblyVersion("1.0.0.0")]
[assembly: System.Reflection.AssemblyKeyFile("Calculator.snk" )]
#endif

namespace Mathematics
{
[ClassInterface(ClassInterfaceType.AutoDual)]
[ProgId("Mathematics.Calculator")]
public class Calculator : Component
{...}
}

Thanks again,

John

"Patrick Steele [MVP]" <pa*****@mvps.org> wrote in message
news:MP************************@msnews.microsoft.c om...
In article <ed*************@TK2MSFTNGP11.phx.gbl>, js******@c-comld.com
says...
Hi All,

I've been working on building a .dll in C# (framework 1.1) and using it
in
VFP8. As always, the example that runs so smoothly in the article
fails
at a rather basic point in practice. When attempting to create the
object,
After building a dll, I used RegAsm.exe to register and received "Types registered successfully" message. But upon trying to create the
object in VFP, I get the error:

OLE error code 0x80070002: The system cannot find the file specified.

Anyone have an idea what (probably basic) thing I'm missing here?


Usually, .NET assemblies reside in the same directory as the executable
(even with COM-interop). I've had this happen before when doing stuff
inside the VB6 IDE. I had to place the .NET assembly in the same
directory as the IDE (VB6.EXE). Perhaps VFP needs this to.

--
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net/psteele


Nov 15 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.