ProFoxers,
I've started down the road of attempting to create a DLL in C# using VS2019. Here's the problem I'm trying to solve.
I want to retrieve the current orientation value from a JPG. If it exists, I want to rotate the image to that value. Finally I want to set/delete the orientation tag.
I found a lovely .Net code sample that describes the problem and appears to do exactly what I want. You can see the source here:
https://www.ryadel.com/en/change-image-orientation-iphone-andor-android-phone-pics-net-c/
Now assuming this code works, the trick is how to get it into a DLL that I can call from VFP. I've created a Helper class project in VS; got it to build the DLL cleanly and that's where I start running into a brick wall. I used a white paper from Doug Hennig as a guideline on how to invoke from a PRG using wwDotNetBridge and InvokeStaticMethod. Sadly all I've been gotten from that call is a NULL. Then I tried to debug using VS and it tells me I can't debug a Helper DLL; I have to add an executable thing-a-ma-jig to the project. (As you can see my VS knowledge is a bit...lacking.)
Tips, tricks and tutorial hints gratefully accepted. I'm happy to get more into actual code once I have enough of a foundation to actually discuss this intelligently. 😊
--
rk
Richard I assume you created a project of type 'Class Library'. No you can't debug those, you need to host it in some other sort of exectuable project. To debug that you either need to add another project of a type that is executable to your solution (like a Windows Forms, WPF or Console application) and reference the output from the first project in that, so you can test it. You need to right-click on that project in Solution Explorer and select 'Set As Startup Project'.
Normally I would recommend to test it on the .NET side you actually use a proper testing framework like MSTest or NUnit. However what you're trying to really needs to be checked visually so that's probably overkill initially.
Did you make the relevant methods COM-visible, i.e. like:
[ComVisible(true)] [Guid("8C019E76-59BE-43A6-9DD9-66F7C9CAE67B")] [ProgId("MyApp.ExcelConvert")] [ClassInterface(ClassInterfaceType.AutoDual)] [ComSourceInterfaces(typeof(IExcelConvertEvents))] public class ExcelConvertHelper { ... }
I must confess I've never gotten the wwDotNetBridge registration-free COM to work. I've always had to add an installer project in .NET and just make users install and register the assembly.
Don't forget you have to build it as 32-bit to use it from VFP.
Thanks, Alan, much appreciated.
I was just going through the various build options. The 32 bit thing will be a the top of the checklist.
I thought there was a magic way to connect the debugger to an external process (e.g. VFP). There's some stuff in Doug's white paper on how to do that but I'm just at the beginning of this journey.
--
rk
From: ProfoxTech profoxtech-bounces@leafe.com On Behalf Of Alan Bourke Sent: Tuesday, April 4, 2023 10:36 AM To: profoxtech@leafe.com Subject: Re: Fun with .Net DLLs
Richard I assume you created a project of type 'Class Library'. No you can't debug those, you need to host it in some other sort of exectuable project. To debug that you either need to add another project of a type that is executable to your solution (like a Windows Forms, WPF or Console application) and reference the output from the first project in that, so you can test it. You need to right-click on that project in Solution Explorer and select 'Set As Startup Project'.
Normally I would recommend to test it on the .NET side you actually use a proper testing framework like MSTest or NUnit. However what you're trying to really needs to be checked visually so that's probably overkill initially.
Did you make the relevant methods COM-visible, i.e. like:
[ComVisible(true)] [Guid("8C019E76-59BE-43A6-9DD9-66F7C9CAE67B")] [ProgId("MyApp.ExcelConvert")] [ClassInterface(ClassInterfaceType.AutoDual)] [ComSourceInterfaces(typeof(IExcelConvertEvents))] public class ExcelConvertHelper { ... }
I must confess I've never gotten the wwDotNetBridge registration-free COM to work. I've always had to add an installer project in .NET and just make users install and register the assembly.
Don't forget you have to build it as 32-bit to use it from VFP.
-- Alan Bourke alanpbourke (at) fastmail (dot) fm
[excessive quoting removed by server]
Richard it is relatively simple.
Done it many times but not for a while - I'll hunt down my notes and get something to you. Essentially it is making the .Net assembly com visible and then it is easy to use in VFP.
I'll do that this evening.
Cheers
-----Original Message----- From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Richard Kaye Sent: Wednesday, 5 April 2023 1:37 AM To: profoxtech@leafe.com Subject: RE: Fun with .Net DLLs
Thanks, Alan, much appreciated.
I was just going through the various build options. The 32 bit thing will be a the top of the checklist.
I thought there was a magic way to connect the debugger to an external process (e.g. VFP). There's some stuff in Doug's white paper on how to do that but I'm just at the beginning of this journey.
--
rk
From: ProfoxTech profoxtech-bounces@leafe.com On Behalf Of Alan Bourke Sent: Tuesday, April 4, 2023 10:36 AM To: profoxtech@leafe.com Subject: Re: Fun with .Net DLLs
Richard I assume you created a project of type 'Class Library'. No you can't debug those, you need to host it in some other sort of exectuable project. To debug that you either need to add another project of a type that is executable to your solution (like a Windows Forms, WPF or Console application) and reference the output from the first project in that, so you can test it. You need to right-click on that project in Solution Explorer and select 'Set As Startup Project'.
Normally I would recommend to test it on the .NET side you actually use a proper testing framework like MSTest or NUnit. However what you're trying to really needs to be checked visually so that's probably overkill initially.
Did you make the relevant methods COM-visible, i.e. like:
[ComVisible(true)] [Guid("8C019E76-59BE-43A6-9DD9-66F7C9CAE67B")] [ProgId("MyApp.ExcelConvert")] [ClassInterface(ClassInterfaceType.AutoDual)] [ComSourceInterfaces(typeof(IExcelConvertEvents))] public class ExcelConvertHelper { ... }
I must confess I've never gotten the wwDotNetBridge registration-free COM to work. I've always had to add an installer project in .NET and just make users install and register the assembly.
Don't forget you have to build it as 32-bit to use it from VFP.
-- Alan Bourke alanpbourke (at) fastmail (dot) fm
[excessive quoting removed by server]
Thanks, Darren! Much appreciated.
I've got the DLL building OK in VS but figuring out how to debug is a challenge. Apparently because the solution is a "Helper" class library, direct debugging is not possible. In VFP I'm using wwDotNetBridge to load the assembly which appears to succeed but when I attempt to invoke the static method it returns a null. Until I can figure out the debugging process it's an arduous process. Rick Strahl has a pretty extensive white paper on how to do this sort of stuff but the learning curve is steep for an old VFP guy...
--
rk
From: ProfoxTech profoxtech-bounces@leafe.com On Behalf Of Darren Sent: Tuesday, April 4, 2023 10:53 PM To: profoxtech@leafe.com Subject: RE: Fun with .Net DLLs
Richard it is relatively simple.
Done it many times but not for a while - I'll hunt down my notes and get something to you. Essentially it is making the .Net assembly com visible and then it is easy to use in VFP.
I'll do that this evening.
Cheers
-----Original Message----- From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Richard Kaye Sent: Wednesday, 5 April 2023 1:37 AM To: profoxtech@leafe.commailto:profoxtech@leafe.com Subject: RE: Fun with .Net DLLs
Thanks, Alan, much appreciated.
I was just going through the various build options. The 32 bit thing will be a the top of the checklist.
I thought there was a magic way to connect the debugger to an external process (e.g. VFP). There's some stuff in Doug's white paper on how to do that but I'm just at the beginning of this journey.
--
rk
From: ProfoxTech <profoxtech-bounces@leafe.commailto:profoxtech-bounces@leafe.com> On Behalf Of Alan Bourke Sent: Tuesday, April 4, 2023 10:36 AM To: profoxtech@leafe.commailto:profoxtech@leafe.com Subject: Re: Fun with .Net DLLs
Richard I assume you created a project of type 'Class Library'. No you can't debug those, you need to host it in some other sort of exectuable project. To debug that you either need to add another project of a type that is executable to your solution (like a Windows Forms, WPF or Console application) and reference the output from the first project in that, so you can test it. You need to right-click on that project in Solution Explorer and select 'Set As Startup Project'.
Normally I would recommend to test it on the .NET side you actually use a proper testing framework like MSTest or NUnit. However what you're trying to really needs to be checked visually so that's probably overkill initially.
Did you make the relevant methods COM-visible, i.e. like:
[ComVisible(true)] [Guid("8C019E76-59BE-43A6-9DD9-66F7C9CAE67B")] [ProgId("MyApp.ExcelConvert")] [ClassInterface(ClassInterfaceType.AutoDual)] [ComSourceInterfaces(typeof(IExcelConvertEvents))] public class ExcelConvertHelper { ... }
I must confess I've never gotten the wwDotNetBridge registration-free COM to work. I've always had to add an installer project in .NET and just make users install and register the assembly.
Don't forget you have to build it as 32-bit to use it from VFP.
-- Alan Bourke alanpbourke (at) fastmail (dot) fm
[excessive quoting removed by server]
On Wed, 5 Apr 2023, at 1:15 PM, Richard Kaye wrote:
Apparently because the solution is a "Helper" class library, direct debugging is not possible.
How you test it is to add another class library project to the solution. Then install the NUnit package (or MSTest, or one of the others). Create a class like this in the test project:
https://gist.github.com/AlanPBourke/cb615f95508a0639605cc7038fe5a7a2
Those methods decorated with [Test] will then be visible in Visual Studio Test Explorer (View menu\Test Explorer). You can then run the tests individually or as a group.
If you want to debug, set a breakpoint in your class being tested, then right-click on the test in Test Explorer and select 'Debug'. Debugging then will proceed as normal.
What are you expecting in the debug/test? In my mind, I'd make a console app and reference this picture dll you made. That console will act like VFP in the pass something to the DLL and receive the output in some way or another.
I have been too busy to read the code you presented. Are you expecting to pass a path\file and get the modified path\Newfile back, or was this streaming the file in memory to you that you catch the stream and do with it as you pleased?
On Wed, Apr 5, 2023 at 7:15 AM Richard Kaye rkaye@invaluable.com wrote:
Thanks, Darren! Much appreciated.
I've got the DLL building OK in VS but figuring out how to debug is a challenge. Apparently because the solution is a "Helper" class library, direct debugging is not possible. In VFP I'm using wwDotNetBridge to load the assembly which appears to succeed but when I attempt to invoke the static method it returns a null. Until I can figure out the debugging process it's an arduous process. Rick Strahl has a pretty extensive white paper on how to do this sort of stuff but the learning curve is steep for an old VFP guy...
--
rk
From: ProfoxTech profoxtech-bounces@leafe.com On Behalf Of Darren Sent: Tuesday, April 4, 2023 10:53 PM To: profoxtech@leafe.com Subject: RE: Fun with .Net DLLs
Richard it is relatively simple.
Done it many times but not for a while - I'll hunt down my notes and get something to you. Essentially it is making the .Net assembly com visible and then it is easy to use in VFP.
I'll do that this evening.
Cheers
-----Original Message----- From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Richard Kaye Sent: Wednesday, 5 April 2023 1:37 AM To: profoxtech@leafe.commailto:profoxtech@leafe.com Subject: RE: Fun with .Net DLLs
Thanks, Alan, much appreciated.
I was just going through the various build options. The 32 bit thing will be a the top of the checklist.
I thought there was a magic way to connect the debugger to an external process (e.g. VFP). There's some stuff in Doug's white paper on how to do that but I'm just at the beginning of this journey.
--
rk
From: ProfoxTech <profoxtech-bounces@leafe.commailto: profoxtech-bounces@leafe.com> On Behalf Of Alan Bourke Sent: Tuesday, April 4, 2023 10:36 AM To: profoxtech@leafe.commailto:profoxtech@leafe.com Subject: Re: Fun with .Net DLLs
Richard I assume you created a project of type 'Class Library'. No you can't debug those, you need to host it in some other sort of exectuable project. To debug that you either need to add another project of a type that is executable to your solution (like a Windows Forms, WPF or Console application) and reference the output from the first project in that, so you can test it. You need to right-click on that project in Solution Explorer and select 'Set As Startup Project'.
Normally I would recommend to test it on the .NET side you actually use a proper testing framework like MSTest or NUnit. However what you're trying to really needs to be checked visually so that's probably overkill initially.
Did you make the relevant methods COM-visible, i.e. like:
[ComVisible(true)] [Guid("8C019E76-59BE-43A6-9DD9-66F7C9CAE67B")] [ProgId("MyApp.ExcelConvert")] [ClassInterface(ClassInterfaceType.AutoDual)] [ComSourceInterfaces(typeof(IExcelConvertEvents))] public class ExcelConvertHelper { ... }
I must confess I've never gotten the wwDotNetBridge registration-free COM to work. I've always had to add an installer project in .NET and just make users install and register the assembly.
Don't forget you have to build it as 32-bit to use it from VFP.
-- Alan Bourke alanpbourke (at) fastmail (dot) fm
[excessive quoting removed by server]
I want to debug anywhere I can solve my problem. 😊
Because I’m a VFP guy I’m trying to attach the VS debugger to the VFP process so I can debug wherever I want. But I’m such a n00b with VS that my progress is glacial…
--
rk
From: ProfoxTech profoxtech-bounces@leafe.com On Behalf Of Stephen Russell Sent: Wednesday, April 5, 2023 10:21 AM To: profoxtech@leafe.com Subject: Re: Fun with .Net DLLs
What are you expecting in the debug/test? In my mind, I'd make a console app and reference this picture dll you made. That console will act like VFP in the pass something to the DLL and receive the output in some way or another.
I have been too busy to read the code you presented. Are you expecting to pass a path\file and get the modified path\Newfile back, or was this streaming the file in memory to you that you catch the stream and do with it as you pleased?
On Wed, Apr 5, 2023 at 7:15 AM Richard Kaye <rkaye@invaluable.commailto:rkaye@invaluable.com> wrote:
Thanks, Darren! Much appreciated.
I've got the DLL building OK in VS but figuring out how to debug is a challenge. Apparently because the solution is a "Helper" class library, direct debugging is not possible. In VFP I'm using wwDotNetBridge to load the assembly which appears to succeed but when I attempt to invoke the static method it returns a null. Until I can figure out the debugging process it's an arduous process. Rick Strahl has a pretty extensive white paper on how to do this sort of stuff but the learning curve is steep for an old VFP guy...
--
rk
From: ProfoxTech <profoxtech-bounces@leafe.commailto:profoxtech-bounces@leafe.com> On Behalf Of Darren Sent: Tuesday, April 4, 2023 10:53 PM To: profoxtech@leafe.commailto:profoxtech@leafe.com Subject: RE: Fun with .Net DLLs
Richard it is relatively simple.
Done it many times but not for a while - I'll hunt down my notes and get something to you. Essentially it is making the .Net assembly com visible and then it is easy to use in VFP.
I'll do that this evening.
Cheers
-----Original Message----- From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Richard Kaye Sent: Wednesday, 5 April 2023 1:37 AM To: profoxtech@leafe.com<mailto:profoxtech@leafe.commailto:profoxtech@leafe.com%3cmailto:profoxtech@leafe.com> Subject: RE: Fun with .Net DLLs
Thanks, Alan, much appreciated.
I was just going through the various build options. The 32 bit thing will be a the top of the checklist.
I thought there was a magic way to connect the debugger to an external process (e.g. VFP). There's some stuff in Doug's white paper on how to do that but I'm just at the beginning of this journey.
--
rk
From: ProfoxTech <profoxtech-bounces@leafe.com<mailto:
mailto:profoxtech-bounces@leafe.com%3cmailto:%0b> profoxtech-bounces@leafe.commailto:profoxtech-bounces@leafe.com>> On Behalf Of Alan Bourke
Sent: Tuesday, April 4, 2023 10:36 AM To: profoxtech@leafe.com<mailto:profoxtech@leafe.commailto:profoxtech@leafe.com%3cmailto:profoxtech@leafe.com> Subject: Re: Fun with .Net DLLs
Richard I assume you created a project of type 'Class Library'. No you can't debug those, you need to host it in some other sort of exectuable project. To debug that you either need to add another project of a type that is executable to your solution (like a Windows Forms, WPF or Console application) and reference the output from the first project in that, so you can test it. You need to right-click on that project in Solution Explorer and select 'Set As Startup Project'.
Normally I would recommend to test it on the .NET side you actually use a proper testing framework like MSTest or NUnit. However what you're trying to really needs to be checked visually so that's probably overkill initially.
Did you make the relevant methods COM-visible, i.e. like:
[ComVisible(true)] [Guid("8C019E76-59BE-43A6-9DD9-66F7C9CAE67B")] [ProgId("MyApp.ExcelConvert")] [ClassInterface(ClassInterfaceType.AutoDual)] [ComSourceInterfaces(typeof(IExcelConvertEvents))] public class ExcelConvertHelper { ... }
I must confess I've never gotten the wwDotNetBridge registration-free COM to work. I've always had to add an installer project in .NET and just make users install and register the assembly.
Don't forget you have to build it as 32-bit to use it from VFP.
-- Alan Bourke alanpbourke (at) fastmail (dot) fm
[excessive quoting removed by server]
_______________________________________________ Post Messages to: ProFox@leafe.commailto:ProFox@leafe.com Subscription Maintenance: https://mail.leafe.com/mailman/listinfo/profoxhttps://protect-us.mimecast.com/s/mTo7CyP6D9T3R6muNi7ds?domain=mail.leafe.com OT-free version of this list: https://mail.leafe.com/mailman/listinfo/profoxtechhttps://protect-us.mimecast.com/s/4xBqCzpBE7uzA8NhwhdIF?domain=mail.leafe.com Searchable Archive: https://leafe.com/archiveshttps://protect-us.mimecast.com/s/krSVCADQ2MI5zrJI2wFLJ?domain=leafe.com This message: https://leafe.com/archives/byMID/CAJidMY+uBX81Q9K4m8ymz9AuZ3B3SZT1bM_xzgiQL_...https://protect-us.mimecast.com/s/ldMFCBB82PuNOPJTrMagu?domain=leafe.com ** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
NP. I don't know if you can do that from VFP because I have no experience in it.
There is a free tool from M$ called VS Code that works on everything and works everywhere. I found this and you can add in the ability to work with VFP code they say. https://github.com/mattslay/Visual-FoxPro-language-template-for-Visual-Studi...
Not sure if this helps or only muddies the waters.
From a web development perspective, VS Code allows you to work with so many
different things that it is becoming an editor for almost everyone. Htmt, CSS, javascript frameworks of the day, python, oh yeah .net as well.
On Wed, Apr 5, 2023 at 11:43 AM Richard Kaye rkaye@invaluable.com wrote:
I want to debug anywhere I can solve my problem. 😊
Because I’m a VFP guy I’m trying to attach the VS debugger to the VFP process so I can debug wherever I want. But I’m such a n00b with VS that my progress is glacial…
--
rk
From: ProfoxTech profoxtech-bounces@leafe.com On Behalf Of Stephen Russell Sent: Wednesday, April 5, 2023 10:21 AM To: profoxtech@leafe.com Subject: Re: Fun with .Net DLLs
What are you expecting in the debug/test? In my mind, I'd make a console app and reference this picture dll you made. That console will act like VFP in the pass something to the DLL and receive the output in some way or another.
I have been too busy to read the code you presented. Are you expecting to pass a path\file and get the modified path\Newfile back, or was this streaming the file in memory to you that you catch the stream and do with it as you pleased?
On Wed, Apr 5, 2023 at 7:15 AM Richard Kaye <rkaye@invaluable.commailto: rkaye@invaluable.com> wrote:
Thanks, Darren! Much appreciated.
I've got the DLL building OK in VS but figuring out how to debug is a challenge. Apparently because the solution is a "Helper" class library, direct debugging is not possible. In VFP I'm using wwDotNetBridge to load the assembly which appears to succeed but when I attempt to invoke the static method it returns a null. Until I can figure out the debugging process it's an arduous process. Rick Strahl has a pretty extensive white paper on how to do this sort of stuff but the learning curve is steep for an old VFP guy...
--
rk
From: ProfoxTech <profoxtech-bounces@leafe.com<mailto:
profoxtech-bounces@leafe.com>> On Behalf Of Darren
Sent: Tuesday, April 4, 2023 10:53 PM To: profoxtech@leafe.commailto:profoxtech@leafe.com Subject: RE: Fun with .Net DLLs
Richard it is relatively simple.
Done it many times but not for a while - I'll hunt down my notes and get something to you. Essentially it is making the .Net assembly com visible and then it is easy to use in VFP.
I'll do that this evening.
Cheers
-----Original Message----- From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Richard Kaye Sent: Wednesday, 5 April 2023 1:37 AM To: profoxtech@leafe.com<mailto:profoxtech@leafe.com<mailto:
profoxtech@leafe.com%3cmailto:profoxtech@leafe.com>>
Subject: RE: Fun with .Net DLLs
Thanks, Alan, much appreciated.
I was just going through the various build options. The 32 bit thing will be a the top of the checklist.
I thought there was a magic way to connect the debugger to an external process (e.g. VFP). There's some stuff in Doug's white paper on how to do that but I'm just at the beginning of this journey.
--
rk
From: ProfoxTech <profoxtech-bounces@leafe.com<mailto:
mailto:profoxtech-bounces@leafe.com%3cmailto:%0b> profoxtech-bounces@leafe.commailto:profoxtech-bounces@leafe.com>> On Behalf Of Alan Bourke
Sent: Tuesday, April 4, 2023 10:36 AM To: profoxtech@leafe.com<mailto:profoxtech@leafe.com<mailto:
profoxtech@leafe.com%3cmailto:profoxtech@leafe.com>>
Subject: Re: Fun with .Net DLLs
Richard I assume you created a project of type 'Class Library'. No you can't
debug
those, you need to host it in some other sort of exectuable project. To debug that you either need to add another project of a type that is executable to your solution (like a Windows Forms, WPF or Console application) and reference the output from the first project in that, so you can test it. You need to right-click on that project in Solution Explorer and select 'Set As Startup Project'.
Normally I would recommend to test it on the .NET side you actually use a proper testing framework like MSTest or NUnit. However what you're trying to really needs to be checked visually so that's probably overkill
initially.
Did you make the relevant methods COM-visible, i.e. like:
[ComVisible(true)] [Guid("8C019E76-59BE-43A6-9DD9-66F7C9CAE67B")] [ProgId("MyApp.ExcelConvert")] [ClassInterface(ClassInterfaceType.AutoDual)] [ComSourceInterfaces(typeof(IExcelConvertEvents))] public class ExcelConvertHelper { ... }
I must confess I've never gotten the wwDotNetBridge registration-free COM to work. I've always had to add an installer project in .NET and just make users install and register the assembly.
Don't forget you have to build it as 32-bit to use it from VFP.
-- Alan Bourke alanpbourke (at) fastmail (dot) fm
[excessive quoting removed by server]
I use vs code almost exclusively for all my php work. great tool all kinds of plugins if you want to go to that level.
On Wed, Apr 5, 2023 at 2:39 PM Stephen Russell srussell705@gmail.com wrote:
NP. I don't know if you can do that from VFP because I have no experience in it.
There is a free tool from M$ called VS Code that works on everything and works everywhere. I found this and you can add in the ability to work with VFP code they say.
https://github.com/mattslay/Visual-FoxPro-language-template-for-Visual-Studi...
Not sure if this helps or only muddies the waters.
From a web development perspective, VS Code allows you to work with so
many different things that it is becoming an editor for almost everyone. Htmt, CSS, javascript frameworks of the day, python, oh yeah .net as well.
On Wed, Apr 5, 2023 at 11:43 AM Richard Kaye rkaye@invaluable.com wrote:
I want to debug anywhere I can solve my problem. 😊
Because I’m a VFP guy I’m trying to attach the VS debugger to the VFP process so I can debug wherever I want. But I’m such a n00b with VS that
my
progress is glacial…
--
rk
From: ProfoxTech profoxtech-bounces@leafe.com On Behalf Of Stephen Russell Sent: Wednesday, April 5, 2023 10:21 AM To: profoxtech@leafe.com Subject: Re: Fun with .Net DLLs
What are you expecting in the debug/test? In my mind, I'd make a console app and reference this picture dll you made. That console will act like VFP in the pass something to the DLL and receive the output in some way
or
another.
I have been too busy to read the code you presented. Are you expecting to pass a path\file and get the modified path\Newfile back, or was this streaming the file in memory to you that you catch the stream and do with it as you pleased?
On Wed, Apr 5, 2023 at 7:15 AM Richard Kaye <rkaye@invaluable.com
<mailto:
rkaye@invaluable.com>> wrote:
Thanks, Darren! Much appreciated.
I've got the DLL building OK in VS but figuring out how to debug is a challenge. Apparently because the solution is a "Helper" class library, direct debugging is not possible. In VFP I'm using wwDotNetBridge to
load
the assembly which appears to succeed but when I attempt to invoke the static method it returns a null. Until I can figure out the debugging process it's an arduous process. Rick Strahl has a pretty extensive
white
paper on how to do this sort of stuff but the learning curve is steep
for
an old VFP guy...
--
rk
From: ProfoxTech <profoxtech-bounces@leafe.com<mailto:
profoxtech-bounces@leafe.com>> On Behalf Of Darren
Sent: Tuesday, April 4, 2023 10:53 PM To: profoxtech@leafe.commailto:profoxtech@leafe.com Subject: RE: Fun with .Net DLLs
Richard it is relatively simple.
Done it many times but not for a while - I'll hunt down my notes and
get
something to you. Essentially it is making the .Net assembly com
visible
and then it is easy to use in VFP.
I'll do that this evening.
Cheers
-----Original Message----- From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Richard Kaye Sent: Wednesday, 5 April 2023 1:37 AM To: profoxtech@leafe.com<mailto:profoxtech@leafe.com<mailto:
profoxtech@leafe.com%3cmailto:profoxtech@leafe.com>>
Subject: RE: Fun with .Net DLLs
Thanks, Alan, much appreciated.
I was just going through the various build options. The 32 bit thing
will
be a the top of the checklist.
I thought there was a magic way to connect the debugger to an external process (e.g. VFP). There's some stuff in Doug's white paper on how to
do
that but I'm just at the beginning of this journey.
--
rk
From: ProfoxTech <profoxtech-bounces@leafe.com<mailto:
mailto:profoxtech-bounces@leafe.com%3cmailto:%0b> profoxtech-bounces@leafe.commailto:profoxtech-bounces@leafe.com>> On Behalf Of Alan Bourke
Sent: Tuesday, April 4, 2023 10:36 AM To: profoxtech@leafe.com<mailto:profoxtech@leafe.com<mailto:
profoxtech@leafe.com%3cmailto:profoxtech@leafe.com>>
Subject: Re: Fun with .Net DLLs
Richard I assume you created a project of type 'Class Library'. No you can't
debug
those, you need to host it in some other sort of exectuable project. To debug that you either need to add another project of a type that is executable to your solution (like a Windows Forms, WPF or Console application) and reference the output from the first project in that,
so
you can test it. You need to right-click on that project in Solution
Explorer
and select 'Set As Startup Project'.
Normally I would recommend to test it on the .NET side you actually
use a
proper testing framework like MSTest or NUnit. However what you're
trying
to really needs to be checked visually so that's probably overkill
initially.
Did you make the relevant methods COM-visible, i.e. like:
[ComVisible(true)] [Guid("8C019E76-59BE-43A6-9DD9-66F7C9CAE67B")] [ProgId("MyApp.ExcelConvert")] [ClassInterface(ClassInterfaceType.AutoDual)] [ComSourceInterfaces(typeof(IExcelConvertEvents))] public class ExcelConvertHelper { ... }
I must confess I've never gotten the wwDotNetBridge registration-free
COM
to work. I've always had to add an installer project in .NET and just make users install and register the assembly.
Don't forget you have to build it as 32-bit to use it from VFP.
-- Alan Bourke alanpbourke (at) fastmail (dot) fm
[excessive quoting removed by server]
Oh I’ve been using VS Code for a while. I’ve also got a 66 page white paper from Rick Strahl on .Net interop with a pile of tool recommendations including JetBrains Dotpeek and LinqPad. Many rabbit holes I am diving down…
--
rk
From: ProfoxTech profoxtech-bounces@leafe.com On Behalf Of Stephen Russell Sent: Wednesday, April 5, 2023 3:39 PM To: profoxtech@leafe.com Subject: Re: Fun with .Net DLLs
NP. I don't know if you can do that from VFP because I have no experience in it.
There is a free tool from M$ called VS Code that works on everything and works everywhere. I found this and you can add in the ability to work with VFP code they say. https://github.com/mattslay/Visual-FoxPro-language-template-for-Visual-Studi...https://protect-us.mimecast.com/s/yoCLCPNM9zInkwXUrkZHl?domain=github.com
Not sure if this helps or only muddies the waters.
From a web development perspective, VS Code allows you to work with so many
different things that it is becoming an editor for almost everyone. Htmt, CSS, javascript frameworks of the day, python, oh yeah .net as well.
On Wed, Apr 5, 2023 at 11:43 AM Richard Kaye <rkaye@invaluable.commailto:rkaye@invaluable.com> wrote:
I want to debug anywhere I can solve my problem. 😊
Because I’m a VFP guy I’m trying to attach the VS debugger to the VFP process so I can debug wherever I want. But I’m such a n00b with VS that my progress is glacial…
--
rk
From: ProfoxTech <profoxtech-bounces@leafe.commailto:profoxtech-bounces@leafe.com> On Behalf Of Stephen Russell Sent: Wednesday, April 5, 2023 10:21 AM To: profoxtech@leafe.commailto:profoxtech@leafe.com Subject: Re: Fun with .Net DLLs
What are you expecting in the debug/test? In my mind, I'd make a console app and reference this picture dll you made. That console will act like VFP in the pass something to the DLL and receive the output in some way or another.
I have been too busy to read the code you presented. Are you expecting to pass a path\file and get the modified path\Newfile back, or was this streaming the file in memory to you that you catch the stream and do with it as you pleased?
On Wed, Apr 5, 2023 at 7:15 AM Richard Kaye <rkaye@invaluable.com<mailto:
mailto:rkaye@invaluable.com%3cmailto:%0b> rkaye@invaluable.commailto:rkaye@invaluable.com>> wrote:
Thanks, Darren! Much appreciated.
I've got the DLL building OK in VS but figuring out how to debug is a challenge. Apparently because the solution is a "Helper" class library, direct debugging is not possible. In VFP I'm using wwDotNetBridge to load the assembly which appears to succeed but when I attempt to invoke the static method it returns a null. Until I can figure out the debugging process it's an arduous process. Rick Strahl has a pretty extensive white paper on how to do this sort of stuff but the learning curve is steep for an old VFP guy...
--
rk
From: ProfoxTech <profoxtech-bounces@leafe.com<mailto:
mailto:profoxtech-bounces@leafe.com%3cmailto:%0b> profoxtech-bounces@leafe.commailto:profoxtech-bounces@leafe.com>> On Behalf Of Darren
Sent: Tuesday, April 4, 2023 10:53 PM To: profoxtech@leafe.com<mailto:profoxtech@leafe.commailto:profoxtech@leafe.com%3cmailto:profoxtech@leafe.com> Subject: RE: Fun with .Net DLLs
Richard it is relatively simple.
Done it many times but not for a while - I'll hunt down my notes and get something to you. Essentially it is making the .Net assembly com visible and then it is easy to use in VFP.
I'll do that this evening.
Cheers
-----Original Message----- From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Richard Kaye Sent: Wednesday, 5 April 2023 1:37 AM To: profoxtech@leafe.com<mailto:profoxtech@leafe.com<mailtomailto:profoxtech@leafe.com%3cmailto:profoxtech@leafe.com%3cmailto:
profoxtech@leafe.com%3cmailto:profoxtech@leafe.commailto:profoxtech@leafe.com%3cmailto:profoxtech@leafe.com>>
Subject: RE: Fun with .Net DLLs
Thanks, Alan, much appreciated.
I was just going through the various build options. The 32 bit thing will be a the top of the checklist.
I thought there was a magic way to connect the debugger to an external process (e.g. VFP). There's some stuff in Doug's white paper on how to do that but I'm just at the beginning of this journey.
--
rk
From: ProfoxTech <profoxtech-bounces@leafe.com<mailto:
mailto:profoxtech-bounces@leafe.com%3cmailto:%0b> mailto:profoxtech-bounces@leafe.com%3cmailto:%0b>
profoxtech-bounces@leafe.com<mailto:profoxtech-bounces@leafe.commailto:profoxtech-bounces@leafe.com%3cmailto:profoxtech-bounces@leafe.com>>> On Behalf Of Alan Bourke
Sent: Tuesday, April 4, 2023 10:36 AM To: profoxtech@leafe.com<mailto:profoxtech@leafe.com<mailtomailto:profoxtech@leafe.com%3cmailto:profoxtech@leafe.com%3cmailto:
profoxtech@leafe.com%3cmailto:profoxtech@leafe.commailto:profoxtech@leafe.com%3cmailto:profoxtech@leafe.com>>
Subject: Re: Fun with .Net DLLs
Richard I assume you created a project of type 'Class Library'. No you can't
debug
those, you need to host it in some other sort of exectuable project. To debug that you either need to add another project of a type that is executable to your solution (like a Windows Forms, WPF or Console application) and reference the output from the first project in that, so you can test it. You need to right-click on that project in Solution Explorer and select 'Set As Startup Project'.
Normally I would recommend to test it on the .NET side you actually use a proper testing framework like MSTest or NUnit. However what you're trying to really needs to be checked visually so that's probably overkill
initially.
Did you make the relevant methods COM-visible, i.e. like:
[ComVisible(true)] [Guid("8C019E76-59BE-43A6-9DD9-66F7C9CAE67B")] [ProgId("MyApp.ExcelConvert")] [ClassInterface(ClassInterfaceType.AutoDual)] [ComSourceInterfaces(typeof(IExcelConvertEvents))] public class ExcelConvertHelper { ... }
I must confess I've never gotten the wwDotNetBridge registration-free COM to work. I've always had to add an installer project in .NET and just make users install and register the assembly.
Don't forget you have to build it as 32-bit to use it from VFP.
-- Alan Bourke alanpbourke (at) fastmail (dot) fm
[excessive quoting removed by server]
_______________________________________________ Post Messages to: ProFox@leafe.commailto:ProFox@leafe.com Subscription Maintenance: https://mail.leafe.com/mailman/listinfo/profoxhttps://protect-us.mimecast.com/s/lDaLCQWN26HLyQPC90S8I?domain=mail.leafe.com OT-free version of this list: https://mail.leafe.com/mailman/listinfo/profoxtechhttps://protect-us.mimecast.com/s/hyqFCR6M0PhXz6WH0KTFn?domain=mail.leafe.com Searchable Archive: https://leafe.com/archiveshttps://protect-us.mimecast.com/s/BzNgCVO5k7s8RJyUrAssO?domain=leafe.com This message: https://leafe.com/archives/byMID/CAJidMY+DCdyU0pymH6roxOjYiTLE7Qzy1=R1G9mzUO...https://protect-us.mimecast.com/s/Qb2cCW6wlQh8WEqUBFq5S?domain=leafe.com ** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.