Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VBATools.Repositories.Repository threw an exception #37

Open
EI-Systems opened this issue Nov 18, 2019 · 8 comments
Open

VBATools.Repositories.Repository threw an exception #37

EI-Systems opened this issue Nov 18, 2019 · 8 comments

Comments

@EI-Systems
Copy link

Hi Krish, first of all thanks for your great work - it made me reconsider implementing drag & drop. I adapted it to run in the old mdb format as well (and corrected the missing .Dialog in the open multiple Files as string). If I open my test-database and start drag and drop, all is fine and afterwards my full database works as expected. But if I start my database and want to use your drag & drop, I get a Type initialisation error. I inserted a gdll.class_initialize before the gDll.DLL.Dialog.ShowDialogForFileArray, but it doesn't help. Do I have to do anything on opening the form that I missed? What does the .DragMe do? Regards, Andreas

@krishKM
Copy link
Owner

krishKM commented Nov 18, 2019

Hi Andreas,

What do you mean by

"If I open my test-database and start drag and drop, all is fine and afterwards my full database works as expected"?

If you start your test db first, and then your work db it works but if you start your work db first, it doesn't work?
1> Where is the error happening?
2> Any/all other functions are working?

.DragMe allows you to drag the form you want.

@EI-Systems
Copy link
Author

Hi Krish, exactly. I copied all your modules across and added a button to my form to open your drag and drop functionality:
Private Sub BttnAnhängehinzufügen_Click()

Dim F(5) As String

F(3) = "Png Pictures only |*.png"
F(0) = "All files |*.*"
F(1) = "JPG-Bilder |*.jpg"
F(2) = "Tiff-Scans |*.tif"
F(4) = "PDF |*.pdf"

Dim Files() As String
Dim Verz As String
Dim Datei As String
Dim d As DAO.Database
Dim r As DAO.Recordset
'gDll.Class_Initialize
Files = gDll.DLL.Dialog.ShowDialogForFileArray("Es dürfen mehrere Dateien gleichzeitig eingefügt werden", True, F)

When I step through the code with F8, it just stops at that last line and gives me the error.
If I use Intellisense I see gdll.Dll but after that, it doesn't expand further.
When I downgraded to Access2003 it complained that some functions may not be supported and I could not save your Form1, so I just copied the function I needed. But within the Form1 the Alert buttons are working.

@EI-Systems
Copy link
Author

Sorry, I was wrong! The buttons work when I had opened my test database first. If I just start my work database, the Alert buttons do nothing and the password inputbox gives me the same error.

@EI-Systems
Copy link
Author

test dropdown works, but Rich Dialog complains, that it can't find file or assembly Newtonsoft.JSON, Version 11.0.0.0, culture neutral

@krishKM
Copy link
Owner

krishKM commented Nov 18, 2019

I assume your work database is not loading the dll properly? Please examine the Dll() function in KrishDll class and see 1> if the path of your work database is correct 2> if the dll is being loaded.

Can you also post what version of Access + 32/64bit you are using?
Please make sure you have also copied the bin folder to your work database location. The bin folder has many .dlls including the JSON dlls.

Please also make sure, all the dlls are trusted in your machine by right click => unblock.

@EI-Systems
Copy link
Author

Hi Krish, I'm using Access 32 bit on all machines. One with 2010, one with 2007, one with 2003. Since I got already a Dlls folder under the work directory, I adapted your System Module to add a \Dlls\ to the currentproject.path. I reverted that already without a change. If I run a gdll.class_initialize, I get the following output:
dllobject: VBA_TOOLS.KRISH_VBA_TOOLS
?currentproject.FullName: C:\access\Leerstand.mdb
dllObject.SetAccessApplicationPath CurrentProject.FullName
Is that correct or should it read currentproject.path?
The next line is the gdll.dll.dialog.ShowdialogforfileArray...
It steps through the DLL routine again, sees that the dllobject has got content and ends in the Type initialization error of the repository.
The bin folder is copied to c:\access\bin - when I did that, my test database started working.
I got full access to the dll files - the button to unblock isn't there?
Thanks for your time and your help! Andreas

@krishKM
Copy link
Owner

krishKM commented Nov 18, 2019

it must be like this.

C:\access\Leerstand.mdb
C:\access\vba_Tools.dll
C:\access\bin\{all the dlls that comes with the bin folder}

yes dllObject.SetAccessApplicationPath CurrentProject.FullName is correct.

Since your test Db is working, i'm not sure what causes the work db not to work. TypeInitialization error can also happens if the dlls cannot be loaded/found. The project is compiled with .NET framework 4.6.

in the Dll() try to set th dllObject.ShowDllWarnings = True as true and see if you are receiving any error message when loading the dll

@EI-Systems
Copy link
Author

Hi Krish,
dllobject.ShowDllWarnings does not display extra error messages - and since the test db is working, I don't believe that it might be a compile problem. Just got the idea that there might be a duplicate procedure name - I will check that (access compile runs through fine, though). Regards, Andreas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants