|
|
You're welcome.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
|
|
|
|
|
Visual Studio offers a "show all" button in the solution pane.
|
|
|
|
|
Merci
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
|
|
|
|
|
recently I converted a database migration utility from VB(VS6 sp6) to VB.NET(VS 2008 SP1). It is ported succesfully. I am able to open it development M/C. But if I am trying to open the same application in installer M/C.(Fresh machine) my application is crashing.
can anyone let me know what run time dll should be included so that it will work fine.
System Details
1: XP SP3
asdasdadadasd
|
|
|
|
|
ash mishra wrote: can anyone let me know what run time dll should be included so that it will work fine.
The .NET Framework should be included; the same version that you used to develop against. You can't install just "a few dll's", as most of them have quite some dependencies.
Does your installer have an option to see if there's a .NET framework?
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
1) Open VS 2008 and load the project.
2) Right click the project name in solution explorer and select properties.
3) Select the Compile tab and click the Advanced Compiler Settings
4) Check the target Framework version
5) Install that Framework version on target machine
6) Build project and copy EXE file to target machine
|
|
|
|
|
vb6 sp6 working in virtual XP machine under win 7
This setup has been working fine and the projects have existed for years but a couple of them have started failing to compile
They all compile and run ok with Control F5 (Run with full compile) but when you use the File->Make xxxxx.exe option it works for a while and the progress line of "Writing EXE" partially colours blue and it then stops with
Microsoft Visual Basic, "Unexpected Error" Ok Help
Help tells me I may have a hardware or software error. gee you think
At least one of the failing projects hasn't been modified (using sourcesafe so I can be sure of this) since it last compiled ok
Other projects compile ok
Does anyone have any ideas where to look for more info?
EDIT: Things I have checked
There is plenty of free disk
running the compiler from the command line gives the same result
a repair install doesn't change anything
repeat install of sp6 didn't help
modified 18-Jul-12 7:54am.
|
|
|
|
|
Mike Deeks wrote: Does anyone have any ideas where to look for more info?
In 2008, as that's when extended support for VB6 ended
FWIW;
- Make sure you registered all the controls that you're using
- Compile under Windows XP, or download XP-mode for Windows 7
- Keep removing code (comment it out) until you got something that compiles again
- Start migrating to VB.NET; the compiler is free, and you can mix VB6 and .NET code, using the Interop ToolBox from Microsoft.
- Check if the VB6 IDE created a logfile under C:\Windows\System32, and check the EventLog for clues.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Eddy Vluggen wrote: In 2008, as that's when extended support for VB6 ended
2008 is quite recent really
Thanks for the suggestions
it is possible that upgrading office broke it but that had to be done as office was broken, I will have a look when I did that and perhaps try another virtual machine
I am running under XP, in a virtual though
the code hasn't changed on at least one of the projects that is now failing to compile
I will investigate interop
no IDE log file unfortunately
|
|
|
|
|
Mike Deeks wrote: 2008 is quite recent really
Read that again; extended support ended four years ago.
Imagine your virusscanner being outdated four years.
Mike Deeks wrote: it is possible that upgrading office broke it but that had to be done as office was broken
..and now you have to re-create a working compiler-environment. And those Office-dependencies are usually tied to a specific version.
I suggest you create a minimal build environment in a VM, and keep it clean. That probably involves in listing all your external references and verifying their existence and that those are the correct versions.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Eddy Vluggen wrote: Read that again; extended support ended four years ago.
Imagine your virusscanner being outdated four years.
Your right of course and my comment was not intended to be serious but...
Why should it worry me if the extended support that I never used anyway has expired. As long as the program is a valid method of producing binaries (maybe I should keep quiet about that is it isn't at the moment ) then I see no reason why I shouldn't use it
I like the language and, as the largest project is up to 140,000 lines of code, moving to another development environment is not at all easy but as the whole things changes every few years anyway it is hard to see the point. It would be interesting to know the overall number of developers currently using vb6, vb2005, vb2008, vb2010
I am not a luddite and keep up to date with technology but my grandads King Dick socket set still seems to work as well for me as it did for him when he bought it quite a few years ago
Thank you for your helpful advice
|
|
|
|
|
Mike Deeks wrote: Why should it worry me if the extended support that I never used anyway has expired.
It should worry the owner of the project; if your project is written in a dying language, the project will die along with the language. Unless you have the sources to Windows XP and VB6 (including the dependencies)
Mike Deeks wrote: I like the language and, as the largest project is up to 140,000 lines of code, moving to another development environment is not at all easy
It IS easy - it's also a lot of work, but it ain't complex. The longer you write new code in VB6, the more you'll have to migrate.
Mike Deeks wrote: I am not a luddite and keep up to date with technology but my grandads King Dick socket set still seems to work as well for me as it did for him when he bought it quite a few years ago
Hehe, aight - if it ain't broke, don't fix it. You got a good point there. And yes, I admit that even 16-bit apps from Win3.1 might still run on Win7, but if something goes wrong, you're (almost) on your own.
You can't compare VB6-code to "pascal code", or any other "older" language; VB6 is tied to Microsoft, is proprietary (they own the language), and it will die if they do not support the language actively.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Make sure the folder is writable and that the target .EXE file isn't locked (running) or, even better, doesn't exist already.
|
|
|
|
|
unfortunately all checked and even changed the folder just in case
some projects compile and some give the "unexpected error"
I will have to go through and check references/components to see if there is any commonality
|
|
|
|
|
Either that or the VB6 compiler is finally rotting away. Good riddance!
|
|
|
|
|
Dave Kreskowiak wrote: VB6 compiler is finally rotting away
Wooooot!!!!
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
When you build COM objects, those COM objects get registered. And that means: writing to the registry in a part where a user must not write.
Hence my idea: Do you get the same error when you run the IDE in elevated mode?
|
|
|
|
|
don't think you can elevate on Windows XP SP3
and I am an administrator on the PC
but good thought
|
|
|
|
|
True, the virtual machine has its own registry, and with XP, an administrator can write to that.
|
|
|
|
|
On MSDN, I found code that is designed to change between multiple sound cards on a PC. I need to do this in .NET. I attemped to translate the VB6 code on MSDN (see link) into .NET but wind up with a PInvokeStackImbalence exception.
http://support.microsoft.com/kb/180032[^]
Here is my attempted translation:
Imports System.Runtime.InteropServices
Public Class MediaManager
Structure MCI_WAVE_SET_PARMS
Dim dwCallback As Long
Dim dwTimeFormat As Long
Dim dwAudio As Long
Dim wInput As Long
Dim wOutput As Long
Dim wFormatTag As Integer
Dim wReserved2 As Integer
Dim nChannels As Integer
Dim wReserved3 As Integer
Dim nSamplesPerSec As Long
Dim nAvgBytesPerSec As Long
Dim nBlockAlign As Integer
Dim wReserved4 As Integer
Dim wBitsPerSample As Integer
Dim wReserved5 As Integer
End Structure
Public Enum SoundFlags As UInteger
SND_SYNC = &H0
SND_ASYNC = &H1
SND_NODEFAULT = &H2
SND_MEMORY = &H4
SND_LOOP = &H8
SND_NOSTOP = &H10
SND_NOWAIT = &H2000
SND_ALIAS = &H10000
SND_ALIAS_ID = &H110000
SND_FILENAME = &H20000
SND_RESOURCE = &H40004
End Enum
Private Declare Auto Function PlaySound Lib "winmm.dll" (ByVal pszSound As String, ByVal hmod As UInteger, ByVal fdwSound As UInteger) As Boolean
Private Declare Auto Function mciSendCommand Lib "winmm.dll" Alias "mciSendCommandA" (ByVal wDeviceID As Long, ByVal uMessage As Long, ByVal dwParam1 As Long, ByRef dwParam2 As MCI_WAVE_SET_PARMS) As Long
Sub New()
Dim Parameters As MCI_WAVE_SET_PARMS
mciSendCommand(0, &H80D, &H800000, Parameters)
PlaySound("C:\thermo.wav", 0, SoundFlags.SND_FILENAME Or SoundFlags.SND_ASYNC Or SoundFlags.SND_LOOP)
End Sub
End Class
Can Anyone assist me?
Thanks,
kingneb
|
|
|
|
|
When calling native code from managed code, stack imbalances are most often caused by applying the wrong "calling convention" (which says who, caller or callee, is responsible for cleaning up the stack). You will need to apply an explicit DllImport directive and specify the correct calling convention, most likely StdCall .
You will find an example here[^].
I wrote a little article[^] on P/Invoke, unfortunately it isn't finished yet, so it doesn't have the details for VB.NET; you might find it useful anyway.
|
|
|
|
|
OK, I specified the standard calling convention, but no cigar? I think it is something else unless I am still not using the right calling convention.
Imports System.Runtime.InteropServices
Public Class MediaManager
Structure MCI_WAVE_SET_PARMS
Dim dwCallback As Long
Dim dwTimeFormat As Long
Dim dwAudio As Long
Dim wInput As Long
Dim wOutput As Long
Dim wFormatTag As Integer
Dim wReserved2 As Integer
Dim nChannels As Integer
Dim wReserved3 As Integer
Dim nSamplesPerSec As Long
Dim nAvgBytesPerSec As Long
Dim nBlockAlign As Integer
Dim wReserved4 As Integer
Dim wBitsPerSample As Integer
Dim wReserved5 As Integer
End Structure
Public Enum SoundFlags As UInteger
SND_SYNC = &H0
SND_ASYNC = &H1
SND_NODEFAULT = &H2
SND_MEMORY = &H4
SND_LOOP = &H8
SND_NOSTOP = &H10
SND_NOWAIT = &H2000
SND_ALIAS = &H10000
SND_ALIAS_ID = &H110000
SND_FILENAME = &H20000
SND_RESOURCE = &H40004
End Enum
Private Declare Auto Function PlaySound Lib "winmm.dll" (ByVal pszSound As String, ByVal hmod As UInteger, ByVal fdwSound As UInteger) As Boolean
<DllImport("winmm.dll", CallingConvention:=CallingConvention.StdCall)>
Private Shared Function mciSendCommand(ByVal wDeviceID As Long, ByVal uMessage As Long, ByVal dwParam1 As Long, ByRef dwParam2 As MCI_WAVE_SET_PARMS) As Long
End Function
Sub New()
Dim Parameters As MCI_WAVE_SET_PARMS
mciSendCommand(0, &H80D, &H800000, Parameters)
PlaySound("C:\thermo.wav", 0, SoundFlags.SND_FILENAME Or SoundFlags.SND_ASYNC Or SoundFlags.SND_LOOP)
End Sub
End Class
Thanks,
kingneb
|
|
|
|
|
Are you still getting StackImbalance exceptions, or something else?
Using P/Invoke is very similar to programming assembly code, it requires great meticulousness.
In this short time, you did not read the MS link I provided and my article. If you had, you would know that data types differ in managed and native worlds, so your long s very likely are wrong too. And there may be more. Don't expect this to work in a matter of minutes, start with a simple function and get that working, then build from there.
Take your time, experiment, learn the technology. And when you run into real trouble, ask specific questions providing detailed and accurate observations. "No cigar" isn't helpful.
|
|
|
|
|
On top of what Luc said, if you're converting VB6 code to VB.NET the biggest trip is using the wrong data types:
VB6 type VB.NET type
--------- = ------------
Byte Byte 8-bit unsigned integer
Integer Short 16-bit signed integer
Long Integer 32-bit signed integer
Single Single 32-bit floating point
Double Double 64-bit floating point
Currency Decimal (not a direct conversion)
When the function you're calling expects a certain size value, using the wrong type will most assuredly screw up the stack.
Also, you may want to bookmark P/Ivoke.net. It has the correct signatures for most Win32 functions for C# and VB.NET. For example, PlaySound[^] and mciSendString[^], as well as tons more.
|
|
|
|