build lua in visual studio, 'setfenv' cannot change environment of given object - visual-studio-2010

I want to build lua-5.1.4 with Visual Studio 2010; everything seems OK, but the following script:
local P = {}
P._G = _G
if _REQUIREDNAME == nil then
smartinput = P
else
_G[_REQUIREDNAME] = P
end
setfenv(1, P)
got the error message:
‘setfenv’ cannot change environment of given object
I got binaries from
http://sigttou.com/lua-visual-studio-2010-2#comment-209
which were also built by Visual Studio 2010. The script works well, but when I use the project file to build the source myself, the error appears again.
What do I need to do to avoid this problem?

Related

Xcode equivalent of Visual Studio's "Find Source"

I am developing on a Qt project, and have installed Qt from their installer onto my computer. In Visual Studio it is simple to debug-step into Qt sources: when I enter a function in an unknown file, it will open a file browser to let me locate the original Qt source code.
Is there an equivalent function in Xcode or LLDB?
The debug information records the location of the QT source files when they were built. You can find this information by doing:
(lldb) image lookup -va main
Address: hello[0x0000000100000f40] (hello.__TEXT.__text + 0)
Summary: hello`main at hello.c:5
Module: file = "/private/tmp/hello", arch = "x86_64"
CompileUnit: id = {0x00000000}, file = "/tmp/hello.c", language = "ISO C:1999"
Function: id = {0x00000026}, name = "main", range = [0x0000000100000f40-0x0000000100000f6d)
FuncType: id = {0x00000026}, decl = hello.c:4, clang_type = "int (void)"
Blocks: id = {0x00000026}, range = [0x100000f40-0x100000f6d)
LineEntry: [0x0000000100000f40-0x0000000100000f56): /tmp/hello.c:5
Symbol: id = {0x00000004}, range = [0x0000000100000f40-0x0000000100000f6d), name="main"
but substitute some QT function for "main". Then look at the CompileUnit line and see what the "file" entry says. Suppose it says
"/BuildDirectory/sources/SomeSubdirectory/SomeFile.cpp"
Now presumably you've downloaded the QT sources, and they live somewhere on your local machine, say in
"/Users/ME/QT/sources"
So what you want to do is tell lldb: "when you see a source file rooted at /BuildDirectory/sources, look in /Users/ME/QT/sources instead." You do that with the lldb "target.source-map" setting. In this example, you would say:
(lldb) settings set target.source-map /BuildDirectory/sources /Users/ME/QT/sources
You can type that in on the command line or put it in your .lldbinit file for more general use. lldb will update its source maps automatically, but if you are running in Xcode, you'll have to step once after issuing the command to get it to update.

Visual Studio 2010 SP1 setup project doesn't install SP1 of Visual C++ 2010 Runtime Libraries

I'm using VS 2010 SP1 and I've created a VS setup project to install my app. My app uses a DLL written in C++ so I need to include the VC++ 2010 Runtime Libraries.
One of my users reported getting an error while running my installer and I traced it down to the fact that this user already has the SP1 version of the VC++ 2010 Runtime Library installed. My installer tried to install the non-SP1 version and then quit when it saw a newer version already installed (the SP1 version).
I've confirmed this is the source of the problem here: http://social.microsoft.com/Forums/en/crm/thread/db84d4c3-c58e-4ff9-997f-f4e0116bf043 and http://notepad.patheticcockroach.com/1666/installing-visual-c-2010-and-windows-sdk-for-windows-7-offline-installer-and-installation-troubleshooting/
It seems like the only workaround for users is to uninstall the SP1 runtime library and then run my installer. Obviously this is not ideal so I'm looking for a better solution.
The only one I've come up with is to tell my VS setup project to download the runtime library from Microsoft's SP1 link instead (http://download.microsoft.com/download/C/6/D/C6D0FD4E-9E53-4897-9B91-836EBA2AACD3/vcredist_x86.exe). I'm a little worried because this feels like a hack. Anyone have any better ideas?
If it's helpful, here's the install log from the user who hit this bug:
The following properties have been set:
Property: [AdminUser] = true {boolean}
Property: [InstallMode] = HomeSite {string}
Property: [ProcessorArchitecture] = AMD64 {string}
Property: [VersionNT] = 6.1.1 {version}
Running checks for package 'Windows Installer 3.1', phase BuildList
The following properties have been set for package 'Windows Installer 3.1':
Running checks for command 'WindowsInstaller3_1\WindowsInstaller-KB893803-v2-x86.exe'
Result of running operator 'VersionGreaterThanOrEqualTo' on property 'VersionMsi' and value '3.1': true
Result of checks for command 'WindowsInstaller3_1\WindowsInstaller-KB893803-v2-x86.exe' is 'Bypass'
'Windows Installer 3.1' RunCheck result: No Install Needed
Running checks for package 'Visual C++ 2010 Runtime Libraries (x86)', phase BuildList
Running MsiProductCheck with ProductCode '{196BB40D-1578-3D01-B289-BEFC77A11A1E}'
MsiQueryProductState returned '-1'
Setting value '-1 {int}' for property 'VCRedistInstalled'
The following properties have been set for package 'Visual C++ 2010 Runtime Libraries (x86)':
Property: [VCRedistInstalled] = -1 {int}
Running checks for command 'vcredist_x86\vcredist_x86.exe'
Result of running operator 'ValueGreaterThanEqualTo' on property 'VCRedistInstalled' and value '3': false
Result of running operator 'ValueEqualTo' on property 'AdminUser' and value 'false': false
Skipping FailIf because Property 'Version9X' was not defined
Result of running operator 'VersionLessThan' on property 'VersionNT' and value '5.00': false
Result of checks for command 'vcredist_x86\vcredist_x86.exe' is 'Install'
'Visual C++ 2010 Runtime Libraries (x86)' RunCheck result: Install Needed
Running checks for package 'Microsoft .NET Framework 4 Client Profile (x86 and x64)', phase BuildList
Reading value 'Version' of registry key 'HKLM\Software\Microsoft\NET Framework Setup\NDP\v4\Client'
Read string value '4.0.30319'
Setting value '4.0.30319 {string}' for property 'DotNet40Client_TargetVersion'
The following properties have been set for package 'Microsoft .NET Framework 4 Client Profile (x86 and x64)':
Property: [DotNet40Client_TargetVersion] = 4.0.30319 {string}
Running checks for command 'DotNetFX40Client\dotNetFx40_Client_x86_x64.exe'
Result of running operator 'ValueEqualTo' on property 'InstallMode' and value 'HomeSite': true
Result of checks for command 'DotNetFX40Client\dotNetFx40_Client_x86_x64.exe' is 'Bypass'
Running checks for command 'DotNetFX40Client\dotNetFx40_Client_setup.exe'
Result of running operator 'ValueNotEqualTo' on property 'InstallMode' and value 'HomeSite': false
Result of running operator 'VersionGreaterThanOrEqualTo' on property 'DotNet40Client_TargetVersion' and value '4.0.30129': true
Result of checks for command 'DotNetFX40Client\dotNetFx40_Client_setup.exe' is 'Bypass'
'Microsoft .NET Framework 4 Client Profile (x86 and x64)' RunCheck result: No Install Needed
Installation of components 'Visual C++ 2010 Runtime Libraries (x86)' was accepted.
Copying files to temporary directory "C:\Users\JAGDISH\AppData\Local\Temp\VSD653B.tmp\"
Downloading files to "C:\Users\JAGDISH\AppData\Local\Temp\VSD653B.tmp\"
(14-12-2011 14:03:32) Downloading 'vcredist_x86\vcredist_x86.exe' from 'http://go.microsoft.com/fwlink/?LinkID=177916&clcid=0x409' to 'C:\Users\JAGDISH\AppData\Local\Temp\VSD653B.tmp\'
Download completed at 14-12-2011 14:05:00
Verifying file integrity of C:\Users\JAGDISH\AppData\Local\Temp\VSD653B.tmp\vcredist_x86\vcredist_x86.exe
WinVerifyTrust returned 0
File trusted
Running checks for package 'Visual C++ 2010 Runtime Libraries (x86)', phase BeforePackage
Running MsiProductCheck with ProductCode '{196BB40D-1578-3D01-B289-BEFC77A11A1E}'
MsiQueryProductState returned '-1'
Setting value '-1 {int}' for property 'VCRedistInstalled'
The following properties have been set for package 'Visual C++ 2010 Runtime Libraries (x86)':
Property: [VCRedistInstalled] = -1 {int}
Running checks for command 'vcredist_x86\vcredist_x86.exe'
Result of running operator 'ValueGreaterThanEqualTo' on property 'VCRedistInstalled' and value '3': false
Result of running operator 'ValueEqualTo' on property 'AdminUser' and value 'false': false
Skipping FailIf because Property 'Version9X' was not defined
Result of running operator 'VersionLessThan' on property 'VersionNT' and value '5.00': false
Result of checks for command 'vcredist_x86\vcredist_x86.exe' is 'Install'
'Visual C++ 2010 Runtime Libraries (x86)' RunCheck result: Install Needed
Verifying file integrity of C:\Users\JAGDISH\AppData\Local\Temp\VSD653B.tmp\vcredist_x86\vcredist_x86.exe
WinVerifyTrust returned 0
File trusted
Installing using command 'C:\Users\JAGDISH\AppData\Local\Temp\VSD653B.tmp\vcredist_x86\vcredist_x86.exe' and parameters ' /q:a '
Process exited with code 5100
Status of package 'Visual C++ 2010 Runtime Libraries (x86)' after install is 'InstallFailed'
Predefined prerequisites in Visual Studio setup projects are not very good. The fact that they are rarely updated is also a problem.
So the best solution is to create your own custom prerequisite. Visual Studio setup projects do not support custom prerequisite creation. However, it can be done by manually generating the required manifests.
These manifests can be generated automatically with the Bootstrapper Manifest Generator tool.
After generating the package manifests, you can add all these files (including the package) in a separate folder in the Visual Studio prerequisites folder, for example:
C:\Program Files\Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages
This way you can select the prerequisite in your setup project property pages.
Your custom prerequisite can detect both the original runtime and the SP1. You can find the SP1 detection criteria here: http://blogs.msdn.com/b/astebner/archive/2010/05/05/10008146.aspx
I was able to solve this by adding the target output of my c++ DLL to the setup project. Once I did this, the setup project automatically bundled the appropriate c++ dll's with my installer and now everything runs fine.
The original problem was caused by the fact that I had manually checked "C++ Runtime libraries" in the setup project's prerequisites.
#Cosmin Pirvu -- your solution may work, but this is what I ended up doing.

Visual 2010 MFC new project doesn't build!

I just created a new project in Visual 2010. It is a multi-document MFC (static link) application with the HTML help option, Visual Studio 2008 style (with style changing option), that's about it.
Just after creation, I hit Build Solution and I get a lot build errors all in afxcomctl32.h. Errors like:
Error 1 error C2061: syntax error : identifier 'LPCWS' C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include\afxcomctl32.h 426 1
On this line:
AFX_ISOLATIONAWARE_STATICLINK_FUNC(HWND ,CreateWindowExW,(DWORD dwExStyle,LPCWS TR lpClassName,LPCWSTR lpWindowName,DWORD dwStyle,int X,int Y,int nWidth,int nHeight,HWND hWndParent,HMENU hMenu,HINSTANCE hInstance,LPVOID lpParam),(dwExStyle,lpClassName,lpWindowName,dwStyle,X,Y,nWidth,nHeight,hWndParent,hMenu,hInstance,lpParam),NULL)
Same errors in Debug and Release.
My PC is Windows 7 Ultimate. What's the problem???
Best regards,
Downy
AFX_ISOLATIONAWARE_STATICLINK_FUNC(..., LPCWS TR lpClassName, ...)
That code got messed up, there is a space or tab inserted in LPCWSTR. Deleting it will fix the problem.
However, that changed the timestamp on the file as well, you may run into trouble when you install a future service pack. One thing to try is to rename the file, then run a Repair to get the original file back. Or copy it off another machine.

How do I find the path of Visual Studio in the registry using Python?

We have this code, but it doesn't work any more:
def get_vcvarsall(generator):
value = None
type = None
key_name = r'SOFTWARE\Microsoft\VisualStudio\SxS\VC7'
key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, key_name)
if generator.startswith('Visual Studio 8'):
value,type = _winreg.QueryValueEx(key, '8.0')
elif generator.startswith('Visual Studio 9'):
value,type = _winreg.QueryValueEx(key, '9.0')
elif generator.startswith('Visual Studio 10'):
value,type = _winreg.QueryValueEx(key, '10.0')
else:
raise Exception('Cannot determin vcvarsall.bat location for: ' + generator)
path = value + 'vcvarsall.bat'
if not os.path.exists(path):
raise Exception("'%s' not found.")
return path
This seems to have stopped working since I upgraded to Python 2.6 x64 from x86 (but I can't be sure). Could have been upgrading to Win7 that caused the problem.
It's the x64 part.
Since Visual Studio is a 32-bit application, it's registry entries get shoved in the 32-bit WoW dungeon. You'll want to look in
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VS7
Note that if you run Python as a 32-bit executable, it'll get redirected as well -- so everything "just works". It's only when you look for 32-bit information from a 64-bit application or vice versa that you run into problems.

error while trying to create DTE2 Interface object with ruby

I am trying to use ruby win32ole lib and DTE2 Interface to control visual studio 8 \
tried this
require 'win32ole'
ide = WIN32OLE.new('EnvDTE80.DTE2')
and received this error unknown OLE server: EnvDTE80.DTE2
what am I doing wrong, can this work at all ?
you are using the wrong object name, for visual studio 2008 and opening a solution called MySolution.sln :
require 'win32ole'
objDTE = WIN32OLE.new("VisualStudio.DTE.9.0")
objDTE.MainWindow.Visible = true #make VS window visible
objDTE.UserControl = true; #set to false to cause VS to shut down when the script ends
solution = objDTE.Solution
solution.Open("MySolution.sln");

Resources