×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

How to use QR barcodes in an easy way
3

How to use QR barcodes in an easy way

How to use QR barcodes in an easy way

(OP)
We were using FoxbarcodeQR for the longest time, but just realized that it´s QR capabilities are capped to 255 characters. Is anyone using something free/cheap that´s comparable to Foxbarcode?

Best regards Benjamin

RE: How to use QR barcodes in an easy way

I see.

Quote (Project descroiption)

BarCodeLibrary.dll has the limitation of encoding only up to 255 characters, so FoxBarcodeQR also has this limitation.

I first thought you'd fallen for a string literal limit of VFP and not a general String length limit, which is much higher.
But the limit is described as a dependency of a DLL this is based on.

No, I don't have an idea, but I likely may need something more capable, too. The QR Code specifications limit a QR Code to 2953 Bytes of net embeddable information. So it's not a QR specification limit.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: How to use QR barcodes in an easy way

you could switch to a web based QR generator?

e.g.
set library to vfpconnection.fll additive
httpsget("https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=Example","c:\temp\fred.png")

httpsget("https://chart.googleapis.com/chart?cht=qr&chs=300x300&chl=Hello%20world","c:\temp\fred2.png")
 

https://developers.google.com/chart/infographics/d...

google has a 2k limit


of course this runs the risk that one day the api may get deprecated.

hth

n

RE: How to use QR barcodes in an easy way

Indeed possible, but for a POS system that should be able to continue working when the internet connection is lost, I'd need an offline solution. In large amounts any online service could collect too much information, so it should remain a DLL. Currently, I simply hope the 255 character limit doesn't really hit me.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: How to use QR barcodes in an easy way

(OP)
That´s a great solution Nigel, but we need an solution that´s working offline. I didn´t say that in my initial post. Maybe someone else has an idea

RE: How to use QR barcodes in an easy way

Thanks Nigel,

with best intentions. Searching something also new to me I have to first test to work is easy. ActiveX should always work with VFP, but always has the redistribution overhead. I'd even rather take an assembly and Rick Strahls .net Bridge. That's also using COM visibility, but generates it on the fly. And I think I'll use this.

https://github.com/codebude/QRCoder/wiki

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: How to use QR barcodes in an easy way

Are you just after a barcode, or one on a report or what?

I have something that makes a .jpg of anything you want in a QR code - you can then drop that onto a pdf easily enough

Is that the kind of thing you are looking for?

Regards

Griff
Keep Smileing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.

RE: How to use QR barcodes in an easy way

I print POS receipts, there are very specific opes commands for that and indeed I just need a picture file. I need to look what's supported, I think just JPG or BMP/GIF, but I can tell you more on Monday.
Only QR, normal Barcodes are covered by the OPOS printer.

But sorry for the hijacking, of course, the question also goes to wibenji.

I think I get along with what QRCoder gives me. Let me see if that DLL is easy enough to use...

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: How to use QR barcodes in an easy way

Sorry, I use FoxbarcodeQR - I forgot, and didn't reach the limitation.

Regards

Griff
Keep Smileing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.

RE: How to use QR barcodes in an easy way

Well, it comes down to fiscal signatures including a lot of information. It was manageable without FoxBarcdeQR as a DLL I used for Austria included QR Code image generation. For Germany it'll be different. I think they managed to allow printing on usual rather slim receipts. not as Deutsche Bahn Tickets that have to be printed in letter size and are scanned by an equally large scanner that lights up the whole train wagon when your ticket is scanned.

At least that still was so in the 2010s. I think now your phone display is sufficient to display such codes and there are other means, even the simplest paper ticket is often still the simpllest.

I still hope I won't even need to exceed the limit, as I think it'll be unbearable to print small and still scannable. The DLL I used for Austria actually had the option for two QR codes, one larger with more error correction pixels, though. If irony would fit here the smaller one with less error correction would have scanned better, but indeed correction codes worked out fine.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: How to use QR barcodes in an easy way

I got my way into the QRCoder assembly https://github.com/codebude/QRCoder.

The assembly itself fails to be used with Rick Strahls .NET Bridge. I think it's because of too convoluted overloading of methods.
But it's not hard to build a helper assembly for VFP using the QRCoder Nuget package and then essentially the 4 lines of code given as getting started example.

CODE --> C#

using System;
using System.Drawing;
using QRCoder;

namespace VFPQRCoder
{
    public class VFPQRCode
    {
        private QRCodeGenerator _QrGen;

        public VFPQRCode()
        {
            _QrGen = new QRCodeGenerator();
        }

        public void CreateImage(string QrData, string FileName)
        {
            System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
            QRCodeData QrCodeData = _QrGen.CreateQrCode(enc.GetBytes(QrData), QRCodeGenerator.ECCLevel.Q);
            QRCode QrCode = new QRCode(QrCodeData);
            QrCode.GetGraphic(20).Save(FileName);
        }
    }
} 

This is just basic usage without making use of all the features the QRCoder assembly offers in terms of payload definitions etc, but it's easy to extend. For example not hardcode the ECC-level but make that another parameter. What's essential: I tested more than 256 characters string and that's not a problem.

My phone scans the results, for example, this one (that's shorter than 255 bytes, but includes non-ASCII characters like the € sign and umlauts, which are double-byte UTF-8 characters not in the overlap of the first UTF-8 characters with ASCII, just to see that it decodes correctly. (Actual image size was 820x820, I sized it down, and I assume to control that also just needs a bit tweaking).



Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: How to use QR barcodes in an easy way

Just by the way, there is a top banner message on https://developers.google.com/chart/infographics/d... stating this API is deprecated and instead Google Charts should be used.

This bears a few questions: Charts is a much less specific topic, where are QR codes in there? But what's more annoying to you is that they make it a selling point that this API isn't only free but guarantees three years' backward compatibility. I personally would guarantee a longer technical working for a DLL or OCX just from the usual experience of how long legacy software works. And I think the data privacy concern is even a stronger constraint for more cases than you deem it unimportant. Google may not fish all information out of the use of a QR Code generation of every POS receipt, but that they could is concern enough to not use a cloud service like that.

At many times I was standing with the way modern development doesn't only mean shorter release cycles as an advantage for faster progress, but also a pressure on keeping dependencies in sync with current versions and incompatibilities. And here you see the variety of choices will make it easy to switch in three years if it's necessary. But especially a topic like QR codes you develop for a certain central need you don't want to need to come back to as an API you use changes, I'd always pick something that works local for such reasons.

And it's never been an issue that you depend on an older C++ runtime or .net framework. QRCoder does even target .NET standard 1.0, if you need it in a .NET legacy application. It makes a good impression in that aspect. Also what flaws some ActiveX controls we still use and share with the legacy VB community are only deprecated for modern UI reasons, if at all. Not for technical reasons. And that's even lesser a concern for a pixel bitmap that looks like outdated technology from the start anyway.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: How to use QR barcodes in an easy way

(OP)
Olaf I'm looking for the exact same thing. So no problem for hijacking blllttt.
I'll take a look at your last post when I have the time.

RE: How to use QR barcodes in an easy way

(OP)
So i got this working with

CODE --> vfp

LOCAL qrcoder as VFPQRCoder.VFPQRCode
qrcoder = CREATEOBJECT("VFPQRCoder.VFPQRCode")
qrcoder.CreateImage(LC_CSV,"C:/arbeiten/img.jpg") 
but this means i have to register the .dll file. Is there a way to use the CreateImage() method with a

CODE --> vfp

DECLARE CreateImage in vfpqrcode.dll
CreateImage() 
statement? Because right now it says "Cannot find entry point CreateImage in the DLL" when trying this way.

RE: How to use QR barcodes in an easy way

What is the problem with registering the dll?

You can easily incorporate the dll into your exe, extract it at run time and then register it using the code below:

To incorporate the dll, make a free table within your project with two columns, one for an identfier and the other as a binary blob, pop a record in it
complete the identifier (in case you want more binaries later) and use replace mybinary with filetostr("my.dll") to get the binary field populated.
Then when you start the app, write the .dll out to the current folder using strtofile() and register it.


CODE

FUNCTION REGSVR
	* Author.....: William GC Steinford
	* Date.......: Jan 23, 2003
	* Abstract...: Programmatically Register, Unregister an OCX control
	LPARAMETERS PCOCX,PLREG
	LOCAL LLREG
	LLREG = IIF( PCOUNT()>1, PLREG, .T. ) && Default to register

	DECLARE INTEGER LoadLibrary IN kernel32 AS LoadLibraryA STRING lpLibFileName

	LOCAL LHLIB
	LHLIB = LOADLIBRARYA( PCOCX )

	IF (LHLIB < 32) && HINSTANCE_ERROR
		RETURN "ERROR: Could not Load Library "+PCOCX
	ENDIF

	*// Find the entry point.
	DECLARE INTEGER GetProcAddress IN kernel32 INTEGER hModule, STRING lpProcName

	IF LLREG
		LPREGPROC = GETPROCADDRESS(LHLIB, 'DllRegisterServer')
		IF LPREGPROC>0 && Procedure exists!
			DECLARE INTEGER DllRegisterServer IN &pcOCX
			**AS OcxReg
			LNRES = DLLREGISTERSERVER()
			IF LNRES=0
				RETURN "SUCCESS"
			ELSE
				RETURN "ERROR: DllRegisterServer returned "+TRAN(LNRES)
			ENDIF
		ELSE
			* //unable to locate entry point
			RETURN "ERROR: Library "+PCOCX+" has no entry point for DllRegisterServer"
		ENDIF
	ELSE && Unregister
		LPREGPROC = GETPROCADDRESS(LHLIB, 'DllUnregisterServer')
		IF LPREGPROC>0 && Procedure exists!
			DECLARE INTEGER DllUnregisterServer IN &pcOCX
			**AS OcxUnReg
			LNRES = DLLUNREGISTERSERVER()
			IF LNRES=0
				RETURN "SUCCESS"
			ELSE
				RETURN "ERROR: DllUnregisterServer returned "+TRAN(LNRES)
			ENDIF
		ELSE
			* //unable to locate entry point
			RETURN "ERROR: Library "+PCOCX+" has no entry point for DllUnregisterServer"
		ENDIF
	ENDIF
ENDFUNC 

Regards

Griff
Keep Smileing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.

RE: How to use QR barcodes in an easy way

The idea is to use Rick Strtahls bridge on the helper assembly, as the QRCoder.dll seems to evade being controlled by proxy the bridge generates, the VFPQRCoder is that proxy now. So you can avoid registering the self-made helper assmenbly by using Rick Strahls .NET bridge. With the much simpler class structure of just a single method in one parameterization, the bridge has no problems, it only has problems with the much more complex original Qrcoder.DLL assembly, but with the helper that won't become a topic of the bridge.

Maybe Rick Strahl could look into what goes wrong there, but if his bridge doesn't work on a complex assembly, it does work on simpler assemblies and this is the reason I made the helper assembly. To be able to use the bridge.

Otherwise, I could also set some methods and properties COM visible to not need the bridge. But then you need registering.

It's a bit complex logic, but it's relatively easy, just move the goal post a little. The bridge really is a good metaphor you can think of more literally, when you extend the .NET world with a place the bridge can reach, you also can use attached areas of the -NET world, the bridge only needs to be able to reach one landmark of the .NET world, it won't create proxy code to also use System.Drawing, for example, that happens exclusively in the VFPQRCoder when I call Save() and within QRCoder,DLL, when it generates the QRCode image.

The other viable solution would of course is to register that VFPQRCode DLL now, which in turn can use QRCoder.dll unregistered (as it has no COM visibility itself. The original .NET solution owner also suggests using .NET COM visibility as a solution. I could get his solution to compile, I tried to tweak away some of the overloads I didn't need, but still couldn't get it to work with the bridge and didn't want COM visibility as the end solution.

So actually the only goal of the helper assembly is to make it usable for the bridge and avoid a COM visible solution. You can't create assembly DLLs usable via DECLARE. That's just vice versa of why you also can't create VFP DLLs that are usable via declare. Assemblies are closer to COM Servers, just with .NET specific interface and ability to reference them in other .NET projects. Assemblies just keep out of the OLE world but are very similar, which reagasm also suggests. You just have a development platform that allows inclusion of assemblies in projects as part of the project, quite like libs are for C++, so assembly namespaces and "type libs" allow easier code integration into further projects with just DLL inclusion, not heaving over all project source code, too.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: How to use QR barcodes in an easy way

(OP)

Quote (GriffMG)

What is the problem with registering the dll?
Short answer: admin rights.

But thanks anyway for your code, maybe i can use this sometime in the future

Also thanks Olaf for your explanation with the .net Bridge. I´ll have to look deeper into that.

RE: How to use QR barcodes in an easy way

Griff, just one question about registering DLLs with such routines:

Sice Vista, any effort to register something is rerouted to a virtual registry branch and if OLE classes then work, they only can do for the user having these keys. I still think this doesn't work, only when you accept another requirement you can add through manifest: To let your exe require to be run with admin privileges aka elevated. And I like to avoid that need. I don't want an end user application to require him to be admin.

And I don't have customers running all XP or older systems for which such programmatic registering also works non administrative.

It would perhaps be acceptable if all users will need to have their own virtual keys and that works, but I don't think it really does, does it, Griff?

I think this method is broken since Vista.

Last time I remember someone needing registering was just recently with Chilkat solutions. And yes, there is an easy to use bat file available. But isn't it preferable to not need registering? Also not need to put assembles into the global assembly cache (GAC) when they only are special purpose extensions for your applications? I don't see a protection in all this registering need so OLE can find its classes. It doesn't prevent us developers from being very free to do anything on a system within the EXEs we're able to build. And it's only hardship to be able to easier integrate third party libraries in some form of DLL. I would easily do without OLEs class finding mechanism and and reg free usage of them through manifests is another solution, AFAIR that only works for EXEs using the OLE classes.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: How to use QR barcodes in an easy way

By the way, bridge usage for the VFPQRCoder assembly now:

1. put all the files for Rick Strahls' bridge, qrcoder.dll, vfpqrcoder.dll and the following PRG into one folder
2. CD into it (adjust line 2 in the PRG)

CODE

* QRCoder usage
Cd <<qrcoderbridgefolder>> && adjust
Do wwDotNetBridge

LOCAL loBridge as wwDotNetBridge
loBridge = CreateObject("wwDotNetBridge","V4",.f.)
loBridge.LoadAssembly("VFPQRCoder")

Local loVFPQRCoder
loVFPQRCoder = loBridge.CreateInstance('VFPQRCoder.VFPQRCode')
loVFPQRCoder.CreateImage("Test of VFPQRCoder - Äöüßäöüß@€",ADDBS(GETENV("TEMP"))+"testutf8.png") 

No need for registering, neither QRCoder.dll nor VFPQrcoder.dll, only target VFPQRcode.dll to use .NET Framework 4.0, the bridge uses that as default. you could adjust which .NET framework it uses at runtime. That's the part needing to dig a bit deeper into the bridge. Besides loading assemblies and instancing unregistered assembly classes, it also has an InvokeMethod method, where a direct method call doesn't work, but that mechanism also didn't work for the pure QRCoder.dll.

This can be a little bit streamlined as finally all is included in the final EXE anyway (except all the DLL files, I recommend putting them to the EXE = main project folder). So in terms of sorting file type in the project folder structure, you don't need to pull DLLs and PRGs into a libs folder just to get it going within the IDE and in debug sessions of your project, too.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: How to use QR barcodes in an easy way

You may be right Olaf, I might be the only user of the apps using this technique now!

In fact I'm pretty sure I am, and as I have the right privileges, I never see the elevation.

On the other hand, I do use ChilKat on some things, I'll have a look and see if it's registered...

Regards

Griff
Keep Smileing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.

RE: How to use QR barcodes in an easy way

When the app first runs, if there is no ChilKat dll in the folder it's run from, the app extracts the dll as mentioned above and runs that code to register it
and it seems to work in Windows 10.

Can't say any more than that... ChilKat doesn't work unless registered - I don't think - and this is the only route to register it I have.

Not saying you are wrong Olaf, but that is the thing I see before me.

Regards

Griff
Keep Smileing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.

RE: How to use QR barcodes in an easy way

OK,

I also won't question your experience. Maybe you have UAC off, there still are some reasons it could fail under some circumstances. I take it Chilkat doesn't work by just being in the same folder or System32/SysWow64.

It's not that hard to write a VFP COM-Server to check out registration woes to the core extent,I think all do it at some point and check influences of UAC, account type of users. It's astonishing you don't even see an elevation popup, but that would be the case with UAC turned off or to a lower level so it becomes sufficient you're an admin account. It also matters what group policies are set in an environment with Windows Enterprise. That's differences I couldn't currently test, too.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: How to use QR barcodes in an easy way

UAC is strictly enforced, so it's not that, and the users are not ADMINs, although the very first ones, before ChilKat was employed, would have been (because they would have been doing an install).

Dunno.

Regards

Griff
Keep Smileing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.

RE: How to use QR barcodes in an easy way

A setup is always a solution to put in such actions, as they only happen once, but not in a continuous update situation like you have in companies quite frequently.
The same company that required that was willing to assign once for everyone, VFP runtimes and other components including ActiveX a software package needs. GRoup policy is used to prevent and VFP exe to work at any location, though, so it's no free ride, too.

What differed with assemblies is that you don't register them with regsvr32 but regasm. I'm a bit unsure about the aspect of COM visibility, that's still an OLE COM Server thing and registering OLE classes is what regsvr32 is for. For me just another reason to work with regfree manifests and Rick Strahls bridge and avoid ActiveX. Beside the decline of this in OLEDB Providers and ActiveX usage in browsers.

When it comes to components with license the only way even the professional Dev OPS at a customers IT department saw was using the official installer of a component that registered it including license for usage.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: How to use QR barcodes in an easy way

I'm trying an experiment.
I have a server which has never had ChilKat on it, I'm popping a modified exe of the app I was talking about on it. Not installing, it already has the VFP runtimes.

I have changed it so it does not register ChilKat... back in a moment

** update **
Ran without registering ChilKat, did not work, said class definition not present.
Going to log in as ordinary user (was Admin) and see what happens, when I try to register the .dll

** update 2 **
Created new user with remote desktop access, connected, allowed code above to register ChilKat and I sent myself an email
via it. Just checking regedit for ChilKat entries...


** Update 3 **
The ChilKat entries are there in the registry - I can see them from Admin and the new user.

UAC is on, it's Server 2012R2. Go figure

** Update 4 **
The keys in the registry are user based, so without registering the .dll again as Admin, the class does not exist.


Regards

Griff
Keep Smileing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.

RE: How to use QR barcodes in an easy way

Thanks Griff.

Okay, so a per user registering works. It would just be more comfortable to have one administrative registration for all.

I would have bet OLE does not look into user-specific branches of the registry for a class and it's location.

That makes some observations about the uselessness of virtualised keys I learned years ago wrong.

Regarding the .NET bridge one of it's advantages remains, it allows bridging to assemblies without any COM Interop and COM Visible methods and properties/fields.

But several other QR libraries and ActiveX controls also get into an easy enough to use spot. Even when not having the chance to update installations with a regular setup running elevated and only triggering the self registering API functions at first start of a user. The test would be simple, try to create an instance, when it fails selfregister, that should work.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: How to use QR barcodes in an easy way

It does seem clumsy - but makes sense if you are thinking of a licenced product, where some users might not have paid for it and some have maybe?

If you are talking about an RDS installation where there could be fifty users with different privileges?

Getting back to the OP though, he could use the code from William GC Steinford in 2003 regardless of Admin rights.

Regards

Griff
Keep Smileing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.

RE: How to use QR barcodes in an easy way

(OP)
I´m just in the process of trying this. I will report back when i´m done

Edit1: The working .dll i made with Olaf´s help is not registering with the regsvr function. It generates the following error:

CODE --> error

ERROR: Library VFPQRCode has no entry point for DllRegisterServer 

RE: How to use QR barcodes in an easy way

No, it doesn't register, it's an assembly. I wrote I'm unsure whether COM-Visibility changes that, but the registration of assemblies is done with regasm, not regsvr.

Ánd I could have said earlier an assembly has no entry point DllRegisterServer, that's only part of "normal" COM Server DLLs. So that way of registration Griff shows only works for COM Server DLLs. And ActiveX DLLs from third parties will have that. The topic of self-registering won't work with assemblies. Griff's contribution only puts ActiveX alternatives in the spot of being an easy enough update extension.

My main point still is using the .NET bridge. The registration/self-registration process only helps with other actual ActiveX alternatives.

I thought I said everything you need to know about QRCoder and VFPQRCoder. Pick whether you want to avoid the bridge or not. You won't avoid this assembly to need and run in the .NET framework. I still prefer the bridge in that regard, as it's just changing your instancing a bit and the rest of the usage is the same.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: How to use QR barcodes in an easy way

(OP)
The point is that .NET bridge needs .NET Framework which still needs installation. I need a solution that´s fully working without admin rights. I´m not making that decision, i just need to find a way. I will keep trying to find a solution for me. A big thanks to everyone who tried to help me.

RE: How to use QR barcodes in an easy way

.NET 4.0 framework is present. And you can't avoid a .NET framework with a .NET solution, whether you use the bridge or not, that's not the constraint of the bridge.
.NET 4.90 really isn't a constraint.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: How to use QR barcodes in an easy way

(OP)

Quote (Olaf Doschke)

.NET 4.0 framework is present
how do you know that? If that´s the case i could easily use the bridge.

CODE --> vfp

DO wwDotnetBridge
loBridge = GetwwDotnetBridge()
? loBridge.GetDotnetVersion() 
When i use this i´m getting "Unable to load Clr Instance" errors.(wwDotnetBride.dll is not blocked) Sorry but i´m really helpless. Maybe i need to let it rest for a while and come back in a few days.

RE: How to use QR barcodes in an easy way

I have Windows 10 and that also compares with new Server OSes, what are you using?

I also called the bridge differently. Shouldn't matter much, but you can call it to another version and QRCoder.dlls are also available for different versions and you can target your own helper assembly for the version already present.

OSes usually have 2 or 3 versions of the framework, it's not just one, so you have your range of possibilities.

The files you need to run the bridge are
wwDotNetBridge.dll
wwDotNetBridge.xml
wwDotnetBridge.PRG
ClrHost.dll

And then the assembliey
QRCoder.dll"
VFPQRCoder.dll

And then your own PRG

And target what is available to avoid the need of an installation. It would be something that only once needs to be done anyway.
4.0 is there in the most usual cases from XP up to Win10 and the same range of Windows Server versions, ie IIRC 2008-2016?

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: How to use QR barcodes in an easy way

And here's a cut from the brodge PRG code

CODE

FUNCTION Init(lcVersion, llUseCom)

IF !EMPTY(lcVersion)
   LOCAL lcShortVer
   lcShortVer = UPPER(lcVersion)
   DO CASE 
   	CASE lcShortVer == "V4"
   	  lcVersion = "v4.0.30319"
	CASE lcShortVer == "V2"
      lcVersion = "v2.0.50727"     
   ENDCASE

   this.cClrVersion = lcVersion
ENDIF 

It shows that
1. Rick strahl has forseen specifying V2 or V4 in these shortcut versions.
2. You can specify other specific versions.
3. The bridge can also use COM, yes, specified in the second llUseCOM parameter

But what does that mean? You then leave it to the OS COM mechanism, which generally instance OLE classes to also invoke the corresponding runtime. It's still only there when it's there, it's still needing a runtime, nothing runs without a runtime.

Since you target your VFPQRCOder DLL to one or some .NET versions you know what you want. It might be possible to provide several DLLs, as they also come from the QRCoder solution in
...\QRCoder\bin\Release\netstandard2.0
...\QRCoder\bin\Release\net35
...\QRCoder\bin\Release\net40
...\QRCoder\bin\Release\netstandard1.1

When you pick your .NET target version you also pick what QRCoder.dll you'll reference.

Now I think it would get complicated to need to provide a bunch of DLLs to be able to use one of them. Even if COM instancing instead of the bridge loading a .NET version, you'll need to provide versions for the different versions and register them all with regasm. That doesn't make it really simpler. It may then support more customers with what they already have.

But when you reference QRCoder you pick a version already anyway. I picked .NET 4 for my project first and the reference to QRCoder.dll then is its packages\QRCoder.1.4.0\lib\net40\QRCoder.dll, so I am locked in one version the way I configured my project anyway. I could imagine you can also target more versions and have a bunch of outputs like the QRCoder solution. But I don't think that's necessary for the range of OSes supporting 4.0 assemblies is still current Windows and also reaches back to XP. And it contradicts the reason to use the bridge. That use com parameter is okay for system assemblies or the like, available in different versions on different target machines. But if you bring in a software, and then need to bring in several versions and register them with regasm, then you can use it via COM even without the bridge. That doesn't remove complexity.

All that said, I would double-check if the problem you have using the bridge is really your OS or a missing .NET 4.0 version and not just wrong path, missing files from the bridge zip, etc. "V4" is translated to "v4.0.30319" and also is the class definition line cClrVersion = "v4.0.30319". And that was also a reason I targeted .NET 4.0 too. But you are not limited to V2 and V4 parameters and "v4.0.30319" default, you can pass in any concrete version number, too, like a 4.5 version. It's just not a version QRCoder has in its outputs, so you'd have to add it there. Totally possible, I don't think 4.5 deprecates anything that needs special different handling. But I also opted for just using the given binaries from the Nuget source, as I struggled to get the QRCoder solution to compile in the first place, in VS 2017.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: How to use QR barcodes in an easy way

(OP)
Ah the puzzle pieces are slowly making sense to me. I think i can work with that. I also solved the "Unable to load Clr Instance"-Problem by putting the vfp9.exe.config file into the right path. I will now work on making the helper assembly work with all our needs. Again thank you all very very much for your valuable input.

Benjamin Trinkaus

RE: How to use QR barcodes in an easy way

OK,

so I guess I was just more fortunate, but indeed the bridge and it's components never failed for me, even when I first used it on Vista, I think.
I thought you just need to target .NET4 in your helper assembly and then get it going. Maybe add a few files you missed from the bridge, maybe add the correct QrCoder.dll, etc. There's a lot of things that could be "off by one" here.

The idea of regasm differs from ActiveX/COM servers as you usually will stay in the .NET world with assembly usage and go about DLLs as always to avoid DLL hell of some globally registered DLLs, by adding it to the packages your software uses and not register them. That's only necessary - as far as I now dived into it - when you actually need that global visibility even from such languages as VFP without proxies such as Rick Strahl's bridge.

If you do a setup it's quite easy to install dependencies, too. Then anything needing administrative elevation for once is no problem, as setup is having that constraint anyway. OK, and then the bridge even becomes questionable in itself.

I have to cope with many different target systems of a customer distributing his software to multiple customers, too. But it's no problem to specify .net 4.0 as prerequisite then. It'd be something that the distributor would do or even their customers' IT departments. In short, they're having the deployment process under their hands, so I fortunately only explain some things and they figure out more details. Stll usually I aim for them to be able to just distribute a new EXE for updates, and maybe some accompanying files.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: How to use QR barcodes in an easy way

By the way, I made an experiment and changed the target framework version for my VFPQRCoder helper assembly to .NET 4.5 and it still works with the bridge loading the V4 framework.

I ensured the new version DLL is used and not some old DLL version hidden somewhere I don't know by changing the names a bit and I also extended parameters to be able to specify ECC-Level and PixelsperModule.
What's still not under control is the final image size, I think it's simply using a fixed QR pixel size. The most verbose parameterization of GetGraphics allow to set some icon border size, but for the moment that's a side point.

The main point is, it seems not so much important to use exactly the right .NET Framework version at runtime, as long as you stay within overlap of what you're really using. And it's not very much. A bit of Text and encoding (UTF8) and then System.Drawing (.NET GDI+, so to say).

So this is more flexible than I thought and I can't reproduce the problem you have using QRCoder.dll assembly via VFPQRCoder.dll helper assembly via the bridge. I left off COM visibility and didn't register anything.

I think that it works with wrong .NET framework, too, mainly is because I only use the original QRCoder.dll which still targets .NET 4 version. Plus System.Text.UTF8Encoding may not have changed since the beginning of .NET. All in all it's a bit similar to VFP, you can use the VFP9r.dll runtime to run an FXP compiled in VFP6, 7, or 8, too. Just an EXE embeds which runtime version it actually expects, an FXP will be run from some process, it's not an EXE, just ocject code. And VFP object code just like C# CLR code is opcodes interpreted by whatever runtime is active. The opcodes are backward compatible most of the time, even if a native function has one more parameter in VFP9, the main code for the function doesn't change, so the assemblies targeted for 4.5 also can run with various other runtime versions.

I'd not overstretch the flexibility of that, but I wonder how you get to an error at any stage of the process.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: How to use QR barcodes in an easy way

Okay, thanks.

Another thing I automatically not anticipate, as the usual recommendation always is to not run anything from a share directly. That's only causing troubles. CHM help wasn't working from a share, you can't simply replace a file in use by any of the N=? (in a case I maintained 100s) users, the major administrative advantage of a central share is sabotaged by users executing there.

I don't know, XCOPY deployment still involves to only use a share as a repository of the newest versions of files to copy from. But never to use it actively itself. OK, it seems even less modern to use some shell command than using the share itself. You know, there are better tools than XCYOP to copy just newest changed files: robocopy in sync mirror mode. Yes, also just a shell command, but see - it'll even delete files locally, when you delete them from the share, so you gain full control about all user's local directories, not only about the newest file versions, about the full content of that local folder, it'll be a mirror of the server share. To me, that is modern enough.

You can't copy into the system protected c:\Program Files (x86) folder, is that an IT department concern? Well, you can whitelist allowed EXEs in a separate folder, you don't need to lower the security of Program Files(x86) in general, but also could just lower the security of the one company application folder. All possible via group policies. So a separate program folder or one application folder open for overwriting the main executable does not mean an entry point for malware or viruses freely roaming on client workstations as you can pinpoint what's allowed to run there.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: How to use QR barcodes in an easy way

Please, let me just relativize this rant, it's usually addressing a grown situation no single person is responsible for. I removed some parts of the previous post reflecting a bit of bitter experiences, no need to do that here.

And there are still other downsides of the xcopy deployment process, so there is valid criticism, sure, Idially you deploy software the way it's intended. But just a central share is even less ideal. Copying to local, the usual start process becomes giving the users a shortcut to a batchfile making that xcopy/robocopy followed by starting the local exe that may just have been updated, One disadvantage was introduced when Vista allowed to pin an application currently running on the task bar Or in a tile of the start menu in Win8. User do that and (technically) get a shortcut directly to the local EXE, which after that moment now does not update. And I had my pain and learned that the hard way, too.

To overcome that an EXE needs a start code checking it's own version is current. Then starting the EXE directly does not circumvent the update process.

But centralized executable used by many users often mean strange network errors no one can explain, coming from concurrent access the the EXE itself, which VFP never anticipated to be used by multiple users. Concurrent use of the foxuser.dbf intended for use by the one FoxPro user of that executable, and more.

And then you hear them say: "But it works for years". I wonder if they also tell that about their 15 year old car...

OK, so lets reverse this from a rant to constructive advice. Becasue I do think a lot of you already, having managed to follow the steps to create that helper assembly you already proved yourself as "none of them".

You find such deployment scripts here in the FAQ, for example: FAQ184-4492: An Application starter (with auto copy from server into local station).
That's already more than just an cmd batch file with an xcopy.

I do find robocoy very useful, still:

CODE

c:
cd apps\myapp
IF EXIST myapp.exe ren myapp.exe myapp.ex_
robocopy /MIR \\share\apps\myapp\ c:\apps\myapp
IF EXIST myapp.ex_ ren myapp.ex_ myapp.exe
start /b myapp.exe 

This combines the idea of a local apps folder with the idea to let there be no executable file on the share. In this case the EXE file extension is renamed to .EX_ and thus can't be started. The robocopy copies only changed files, so while it runs the EXE has to be named .EX_. After it finishes just rename the local .EX_ to EXE To be able to run it.

But to take the idea to make a version check as start code, I just point out one VFP function: AGETFILEVERSION(). You could compare just a version.txt file that's local to a server share file, but you can do a check that better prevents any cheating when you actually check the version number embedded in your EXE with AGETFILEVERSION(), as this embedded version numbering isn't as easy to manipulate than just a text file.

The concern that this causes a lot of network traffic is not true, the mirror mode means robocopy touches every file, yes, but mainly just its meta data, file size, date, name, to put together a list of files to actually copy. Time to find out nothing changed between central network share and local copy is split seconds, so you get an immediate start.

And then you have all the advantages a local installation has: The only further network load is data access to dbfs, network instabilities won't necessarily affect the local EXE, if you incorporate some behavior how, for example, a POS system stores its receipts local and only commits them at the end of the day, etc. Depends on your needs, of course. Many systems need active central share and won't be of much use in an offline situation, but you're stabilizing that, too.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: How to use QR barcodes in an easy way

(OP)
I´m not sure if this is still directed to me, or just an info for everyone.

I just want to let you know that we are doing something similar. The problem with the dll on an network share was just me messing around in our development environment.

Benjamin Trinkaus

RE: How to use QR barcodes in an easy way

It's okay, I also wouldn't have anticipated that cause for the error.

Just another habit of me to rather test something new completely locally.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: How to use QR barcodes in an easy way

Try this (zip attached to this post)

I put a PJX together with my state of VFPQRCoder.dll and the wwdotnetbridge files as necessary.
I arranged the files as I arrange them in project subfolders.

The project home folder has the PJX, the built EXE and the files you need to redistribute, ie the DLLs of the assemblies and wwdotnetbridge plus XML (I may be wrong about the XML file, but at least it works that way)^. I managed to keep Rick Strahl's code as is, there's no tweaking to let his DECLARE's find DLLs, etc. He has another strategy than I have for specifying file locations, working with many preprocessor directives also differentiating about using the free bridge version or an extended version in the case west wind connect is used. I solve the file finding with SET PATH in main.prg. In general, I often use a project hook to compile a list of locations for SET CLASSLIB, SET PROCEDURE and SET PATH to some sensible paths. I'm no fan of putting everything in one project folder. I can follow the logic of people who do, that the project managers tabs are there to organize the files, you don't need a file explorer to do so. But you know, different people, different OCD. Well, and as long as I only resort files Rickj Strahl intended to be in one folder, that's okay to me. The strongest reason I do so is I don't want DLLs in subfolders. And then I don't want more than necessary files in project home to easily finally pick the files for setup creation. And I want to be able to debug at design time.

The project self adjusts to any place you put it, of course aside of the question coming up when you first open the PJX whether you want to make the current directory the home directory. Of course, yes.

But I mean you just CD into the PJX home folder when you would change something (as include file relative paths depend on that), otherwise, just start the main.prg or the EXE and it'll create some test QR PNG files in the Output directory, no matter what the root directory is. I'd be interested to know whether that really doesn't work when put on a network share. If that's true it should run on any local drive. If it has dependencies to .NET not installed on your system we'll also see. That'd be good to know.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: How to use QR barcodes in an easy way

(OP)
When i start the .exe from my local drive everything works fine. When i put the folder on our network share i get the "Unable to load Clr Instance"-error.
But when i put a file named "vfpqrcodertest.exe.config" with

CODE --> xml

<configuration>
  <runtime>
      <loadFromRemoteSources enabled="true"/>
  </runtime>
</configuration> 
into the same folder it works without the error.

Edit1: (just double clicking the .exe file in each case)

RE: How to use QR barcodes in an easy way

Ah, that's nice to know.

Some .NET runtime detail knowledge acquired...
Thanks, Benjamin.

Didin't you had another blocking problem? Or "just" the wish to use all this via COM instancing and ensuring it works in several client configurations of .NET version availability?

There once was a ClickOnce article to make that the way to handle prerequisites and even have a way to installing without requiring admin permissions. I actually doubt this holds water in the case of a missing .NET 4 Framework version, but perhaps in the usual case. I know it adds "apps" to the c:\users\username\AppData\Local\Apps\2.0

And IIRC such apps then run in lower than usual permissions. But that whole concept seems not to be popular, I only have one subfolder structure and that's empty.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: How to use QR barcodes in an easy way

(OP)
Yeah it´s "just a wish". Some of our clients have really bad hardware companies, and we try to minimize any interaction with them.

RE: How to use QR barcodes in an easy way

OK, one thing is COM doing the instancing and thus loading the CLR, the other is the CLR is still necessary. But as I experimented the dependency is not that strict. It's more about what you use from the framework, and there is very little system assembly usage. System.Drawing, obviously and then a bit Text encodings. Well, and what QRCoder.dll uses (mainly also System.Drawing).

One thing might be worth investigating: How you could tweak QRCoder to work in itself without helper assembly. And then with or without the bridge.
I obviously picked the other route, also because I like to keep thrid party projects untouched only using them as is to be able to update without the need to apply the same tweaks again. I just tried to see what could make it work with the bridge directly. Instancing worked, but the bridge couldn't invoke a method.

Just another hint from a recent question on the inverse situation, trying to use a VFP DLL from Node.js I came across the problem a win32ole module was only working in very old node versions and in itself never was being versioned 1.0, so the originator has abandoned that module. Well, one should perhaps first say that VFPs interop possibilities with DLLs or EXE are only COM interop, you can only crate COM Server DLLs and EXEs, no DLLExport of functions. And then there is the 32bit hurdle...

I got a COM Server in a VFP EXE to work in Node.js with the winax module. That brings back Jsvascripts' ActiveXObject() and to many, that'll cause discomfort. I got no reaction from who asked, so maybe they figured it's not worth it and went another route through ODBC, for example, as it was about DBF data access. Maybe also moved data over to something node can easily address.

So modern platforms don't care for ActiveX/OLE/COM/ADO anymore. MS hs focused on ODBC vs OLEDB providers, too. So the only active use of it I see is with legacy VB6, VFP, and Office VBA, perhaps. And even more exotic languages.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close