error while trying to create DTE2 Interface object with ruby - 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");

Related

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

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?

Word 2010 integration with Visual Studio 2010

I am using the following code which works fine in Visual Studio 2010 integrated Web Server but when deployed on IIS I get error on the ** line:
Word.Application oWord = new Word.Application();
Word.Document oWordDoc; //= new Word.Document();
object breakPage = Word.WdBreakType.wdPageBreak;
oWord.Visible = false;
oWord.Options.set_DefaultFilePath(Microsoft.Office.Interop.Word.WdDefaultFilePath.wdUserTemplatesPath, Server.MapPath(TemplatesFolder)); //#"D:\Presentationalism\Presentationalism\Presentations\Templates");
Object oTemplatePath = Server.MapPath(TemplatesFolder + templates[ddTemplates.SelectedIndex]);
**oWordDoc = oWord.Documents.Add(ref oTemplatePath, ref oMissing, ref oMissing, ref oMissing);**
oWordDoc.Activate();
following is the error:
Word was unable to read this document. It may be corrupt.
Try one or more of the following:
* Open and Repair the file.
* Open the file with the Text Recovery converter.
how do I fix it?

Where is TextTransform.exe Located on Hard drive?

Where is TextTransform.exe located?
I'm trying to implement the solution in this post:
Get Visual Studio to run a T4 Template on every build
However I'm getting an error
"'TextTransform.exe' is not recognized as an internal or external command,
operable program or batch file."
I have been looking through the program files, however not sure where TextTransform.exe is located.
It should be below
\Program Files\Common Files\Microsoft Shared\TextTemplating\
see: http://msdn.microsoft.com/en-us/library/bb126245.aspx
Anyone coming to this question that's using VS 2017 or later should be using vswhere to locate this file. #codingdave's comment is the closest but that still won't work on many computers.
I've added an example to the Microsoft Docs article feedback that shows how to do this with Powershell.
#the path to VSWhere.exe is always in programfiles(x86)
$progFilesx86Path = [System.Environment]::ExpandEnvironmentVariables("%programfiles(x86)%")
$vsWherePath = Join-Path $progFilesx86Path "\Microsoft Visual Studio\Installer\vswhere.exe"
# this tells vswhere to use paths of the latest version of visual studio installed
# to locate this exe anywhere in those paths, and return a single textual
# value (not a json object or xml payload)
$ttExe = & $vsWherePath -latest -find **\TextTransform.exe -format value
if (-Not(Test-Path $ttExe)){
throw "Could not locate TextTransform.exe"
}
#then to invoke a transformation
& "$ttExe" c:\Source\YourTransform.tt
From #codingdave's comment
For VS2017, VS2019 location of TextTransform.exe will be
C:\Program Files (x86)\Microsoft Visual Studio\<<Version>>\<<Edition>>\Common7\IDE
Version -> (2017/2019)
Edition -> (Community/Professional/Enterprise)
And in pre build event we can use macro like
"$(DevEnvDir)\TextTransform.exe" "$(ProjectDir)AssemblyInfo.tt"
I would recommend trying this over that solution: http://www.olegsych.com/2010/04/understanding-t4-msbuild-integration
If you don't have VS 2010, though, I suppose you're stuck doing it the hard way.

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.

SubSonic 3 Regenerate ActiveRecord Class Automatically?

I have a SQLite database and SubSonic3, finally got a clue on how to generate the .cs from the .tt in Visual Studio. My stuff builds now.
I can kick off MSBuild automatically to build my project, but I would like to add a pre-build event to regen the ActiveRecord.cs cleanly so any database changes end up there for future Unit tests.
How can I simulate the 'run external tool' in the Visual Studio GUI?
Thanks.
You can run the TextTemplating tool from the command line:
C:\Program Files\Common Files\Microsoft Shared\TextTemplating\1.2\TextTransform.exe "path/to/your/ttfile.tt" -out <outFileName>
Use TextTransform.exe /help for more command line arguments you can use.
At this time, the SubSonic's Settings.ttinclude file must be run from within the VisualStudio application, and can not be run from the command line. This is because Settings.ttinclude uses the project context to locate the App.config / Web.config file so that it can look up the connection string.
Attempting to run via command line using TextTransform.exe will result in the error:
error : Running transformation: System.InvalidCastException: Unable to cast object of type 'Microsoft.VisualStudio.TextTemplating.CommandLine.CommandLineHost' to type 'System.IServiceProvider'.
This stems from this method in Settings.ttinclude:
public EnvDTE.Project GetCurrentProject() {
IServiceProvider _ServiceProvider = (IServiceProvider)Host;
...
}
By hacking the Settings.ttinclude file, you can set up Subsonic to run from the command line.
Just modify it to set your connection string as the return value of GetConnectionString and taking out all other logic.

Resources