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

Re: Using a .NET component in VFP by Patrick

Patrick
Tue Sep 16 12:56:44 CDT 2003

In article <edViaVGfDHA.556@TK2MSFTNGP11.phx.gbl>, jspiegel@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

Re: Using a .NET component in VFP by John

John
Tue Sep 16 13:43:08 CDT 2003

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]" <patrick@mvps.org> wrote in message
news:MPG.19d118e59ec295bc989805@msnews.microsoft.com...
> In article <edViaVGfDHA.556@TK2MSFTNGP11.phx.gbl>, jspiegel@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



Re: Using a .NET component in VFP by John

John
Tue Sep 16 15:40:22 CDT 2003

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" <jspiegel@c-comld.com> wrote in message
news:eZeW1FIfDHA.2260@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]" <patrick@mvps.org> wrote in message
> news:MPG.19d118e59ec295bc989805@msnews.microsoft.com...
> > In article <edViaVGfDHA.556@TK2MSFTNGP11.phx.gbl>, jspiegel@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
>
>