I am converting from vb5 and have a dll (now converted to VB.NET) which I use for security checks (mysecurity.dll). It contains the class cSecurityCheck and has a few interfaces, as shown in the VB5 code below, which is how I called it in VB5 from my app. I have copied the VB.NET compiled mysecurity.dll to my project's bin directory and added it as a reference to my VB.NET project(project\bin\mysecurity.dll) but in the project calling module (code below) it doesn't recognise CSecurityCheck, saying it has not been defined. How do I call the dll functions?
This dll is used by all my programs and when I finally get to distribute them to a client how do I ensure all the installed executables can look at the one single copy of the dll, which contains the registered user's name?
Dim s As New CSecurityCheck
s.AppPath = Application.StartupPath()
If Not s.DateIsValidated Then
s = Nothing
End
End If
mRegisteredUser = s.RegisteredUser
mDaysRemaining = s.DaysRemaining
s = Nothing
Adding a COM dll to your project automatically creates a namespace for the types in the DLL. Add Imports TheVb5ProjectName at the top of the file.
If you don't know what that name might be (it depends on VB5 project settings) then click the "Show All Files" icon in the Solution Explorer window, open the References node, locate the imported reference. Right-click it and click View in Object Browser.
Related
ActiveX DLL project - running it or Menu > File > Generate Dllname.dll... both produce the error message: Error loading DLL
However, if I open a specific form in design mode then I can compile or run the project without problem.
The form has a MSCAL.OCX v11 Calendar inside.
Note that if I open any other object (classes, forms, etc) continue with the error when try to Run/Compile. Is mandatory to open the frmDate.frm object if I want to Run/Compile the project.
I don't understand why it has this strange behavior and if there is a way to solve it.
Do you have proper appointed the startaup point of the project?
You can do this using this path above:
Go to “Project”->” Properties “, and in the “General” tab select the appropriate form from the “Startup Object” list box.
I want my class library conditionally compiled so that it is in debugging mode when my project is, and is not when my project isn't.
For example, I have this Module in my class library:
Module MyDebug
<Conditional("DEBUG")>
Sub print(ByVal msg As String)
Debug.Print(Now.ToString("yyyy-MM-dd HH:mm:ss.fff") & " " & msg)
End Sub
<Conditional("DEBUG")>
Sub debugEnd(Byval bool As Boolean)
Environment.Exit(0)
End Sub
End Module
When I debug my project which references this library it run any of these when they are called.
I've tried searching online, but I haven't found anything that helps since I can only find things to do with debugging the actually class library, while I only want it to send these conditionally compiled statements while I'm debugging my project.
However, by experimenting around a bit, I've found that if in the class library I go to:
'My Project' -> the 'Compile' tab -> 'Advanced Compile Options'
and then tick 'Define DEBUG constant' (and then build the library), the project does run the debug statements when called.
However, I'm not entirely sure of the behaviour of 'Define DEBUG constant' in the class library. Does it define DEBUG if and only if my project is in debug mode?
If not, then is there a simple way to acheive what I aim to do? (I don't want to have to tick/untick the checkbox in the class library each time I switch between debug and release in my project, and my class library is referenced by more than one project, anyway)
Note that in the project I'm referencing the .dll in the Bin -> Release folder of my class library which I hope is the right way to reference it.
In addition, I would like to ask about how VB acheives this with the Debug class, because it is also imported with a reference like any other class library, and works in the way I would like the above to — surely I could do the same?
If you keep the class library project in the same solution as your main project it will use the same configuration (Debug or Release) as every other project in that solution. This means that you won't have to manually check/uncheck Define DEBUG constant as it will not be defined anyway if you have set the configuration to Release.
Even if your projects are not in the same folder you may still add your class library project to your solution. Here's how to do it:
Right-click your solution in the Solution Explorer and goto Add > Existing Project.
In the file browsing dialog that opens, locate the .vbproj-file of your class library and click OK.
Now when you change compilation configuration it should be reflected over the entire solution and your class library shall only have its DEBUG constant defined if you set the configuration to Debug.
If you cannot see your solution in the Solution Explorer:
In Visual Studio, goto Tools > Options > Projects and Solutions > General.
Check Always show solution and press OK.
For the above to work you must also change the way you reference your class library. The way you are currently doing it is correct, but it won't work in this case as then you'll only be referencing the Release version of your dll.
Start by removing your current reference to your class library.
Open the Add Reference dialog and go to the Projects tab.
Select your class library's project and press OK.
This should now reference the class library's output from the solution's current compilation configuration.
I am trying to generate a manifest for a set of COM objects that are being used in our code as registration-free COM.
For that purpose I created a VB project in VS 2010 and added the COM objects DLLs as dependencies. The problem is I do not see them listed as dependencies in the generated manifest. Am I missing something simple like a project setting to generate the proper manifest listing the dependencies?
You left out too many details and the VB.NET IDE hides too much to do this right. It is not automatic.
Starting point is to force it to show more. Locate the "Show All Files" toolbar button in the Solution Explorer window (use the tooltip to find it back). Click it and you now get the "References" node added to the project.
Open it and locate the COM component that you added to the project. Select it and look at the Properties window. Set the "Isolated" property to True. Rebuild the project. Be sure to look in the Output window for any warnings. And to look at the .manifest file on disk instead of the one the IDE shows you if you added a manifest to your project yourself.
Just to start off, this question does seem very similar to another post Add the DLL (lame_enc.dll) reference to my project, but I haven't been able to successfully apply that answer. I am pretty new to VB.NET so it is very possible I'm simply missing something obvious.
I am trying to link a DLL to a VB.NET 2010 project to allow my VB app to play *.ogg files. I followed some other advice here on the forums and downloaded FMOD's FMOD Ex Programmers API. I am trying to now reference that functionality. These appear to be the files I need to somehow reference.
C:\Program Files (x86)\FMOD SoundSystem\FMOD Programmers API Windows\api\fmodex64.dll.
C:\Program Files (x86)\FMOD SoundSystem\FMOD Programmers API Windows\api\libfmodex64_vc.lib.
I haven't discovered how to add a *.lib reference (or the equivalent), but selecting the DLL as a reference gives the following error.
A reference to 'C:\Program Files (x86)\FMOD SoundSystem\FMOD
Programmers API Windows\api\fmodex64.dll' could not be added. Please
make sure that the file is accessible, and that it is a valid assembly
or COM component.
I'm not sure what I could be missing. Any ideas? Thanks!
In Solution Explorer, double-click the My Project node for the project.
In the Project Designer, click the References tab.
Click the Add button to open the Add Reference dialog box.
In the Add Reference dialog box, select the tab indicating the type of component you want to reference.
Select the components you want to reference, then click OK.
Another approach I was trying is working for me. I found a site with a working example of a LibZPlay VB.NET sample ( http://planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=7789&lngWId=10 ). It runs under VS 2008 and I was able to adapt my project to use LibZPlay (open source library http://libzplay.sourceforge.net/WELCOME.html ) under VS 2008.
That is sufficient for me for now. Thanks for your advice. It was likely some configuration issue or misunderstanding on my end.
Using VB.net 2015 I (could not add or even find a System32 dll) as a reference using Solution Explorer, Tab References. Going to the MAIN Menu, Projects/Add References...
Used Browse and All the System32 dll were visible. Then I was able to load the needed dll.
i want to create resource dll in Vb.net mean like SHELL32.Dll
i want to store my icons and pngs for my custom file extensions.
Thanks..........
This is not supported by the IDE. These resources are not the kind that you're familiar with, they are unmanaged resources. The VB.NET compiler does support the option, /win32resource, you'll however have to run it by hand. You'll also need to run the rc.exe tool by hand to create the .res file.
Using VB.NET is just not the best way to get this done. It is natively supported by the C++ IDE.
File + New + Project
Select Visual C++, Win32, Win32 Project
Next, select DLL
Right-click the Resource Files folder in the Solution Explorer window
Add + Resource, Import and select the icon
Repeat as necessary for every icon you want to add
Build + Build.
You can use View + Other Windows + Resource View to edit the content. One thing you almost certainly want to do is change the ID of the icon from a symbol to a number. That's the number you'll use in the registry entry.
Cant you create a new class library add all of the icons and then change the Resources class to have a public modifier?
EDIT: the resources class is public
The link below works for setting the association: (based on comment feedback)
http://mel-green.com/2009/04/c-set-file-type-association/
You have to create blank DLL project with just added icons to project (not resources).
Check http://msdn.microsoft.com/en-us/library/aa984332(v=vs.71).aspx
VentyCZ