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?
Related
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?
In the construction of the internal representation for a provided type, I call indirectly in the quotation for the internal representation of my type, another dll, whose code I can modify.
Currently, when I consume the type provider, tells me it can't find such dll:
"Could not load file or Assembly xxxx or one of its dependency"
When I inspect VS using Process Explorer, though, I can see the dll XXX loaded...
Are there anything to do to have the code in quotations accept code from outside dll ?
** update **
I tried with a simplified example, and it seems that it is possible to call such outside dll without any special thing to do. In my case, all the dll XXX depends on are loaded, I see them in Process explorer as well as in the modules windows when I debug devenv.exe itself....
I have no idea where to look to. Here is the inner exception.
** update **
If I copy the xxx dll and its dependencies in one of this path, the compiler works fine.
I still wonder what can trigger devenv.exe to correctly show them loaded but not accessible.
=== Pre-bind state information ===
LOG: User = xxx\Administrator
LOG: DisplayName = bloombergapi, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///C:/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/IDE/
LOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\Administrator\AppData\Local\Microsoft\VisualStudio\11.0\devenv.exe.config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/IDE/bloombergapi.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/IDE/bloombergapi/bloombergapi.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/IDE/PublicAssemblies/bloombergapi.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/IDE/PublicAssemblies/bloombergapi/bloombergapi.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/IDE/PrivateAssemblies/bloombergapi.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/IDE/PrivateAssemblies/bloombergapi/bloombergapi.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/bloombergapi.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/bloombergapi/bloombergapi.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/IDE/CommonExtensions/Platform/Debugger/bloombergapi.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/IDE/CommonExtensions/Platform/Debugger/bloombergapi/bloombergapi.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/IDE/PrivateAssemblies/DataCollectors/bloombergapi.DLL.
...
ANSWER
It seems impossible to call a function that takes as an argument a Type from another library.
A union type works, but not a type proper...
This is illustrated below
--Library.dll
namespace Library
module SampleModule =
type LocalUnion = | LocalUnion of int
type Localtype() =
member x.value = 2
--LibraryTP.dll
namespace LibraryTP
module Module =
open System.Reflection
open Samples.FSharp.ProvidedTypes
open FSharpx.TypeProviders.DSL
open Microsoft.FSharp.Core.CompilerServices
let f a =
Library.SampleModule.sampleFunction a a
let g (a:Library.SampleModule.LocalUnion) =
let (Library.SampleModule.LocalUnion(v)) = a
v
let ftype (a:Library.SampleModule.Localtype) =
a.value
let createTP ns =
erasedType<obj> (Assembly.GetExecutingAssembly()) ns "Outside"
|> staticParameter "file"
(fun typeName (parameterValues:string) ->
erasedType<obj> (Assembly.GetExecutingAssembly()) ns typeName
|+!> ( provideProperty
"test" //OK
typeof<float>
(fun args -> <## g ( f 2 ) ##>)
|> makePropertyStatic
)
|+!> ( provideProperty
"test2" //KO
typeof<int>
(fun args -> <## ftype ( Library.SampleModule.Localtype()) ##>)
|> makePropertyStatic
)
)
[<TypeProvider>]
type public CustomTypeProvider(cfg:TypeProviderConfig) as this =
inherit TypeProviderForNamespaces()
do this.AddNamespace("TP", [createTP "TP"])
[<TypeProviderAssembly>]
do()
--Program.fs
type sampleValue = TP.Outside<"">
[<EntryPoint>]
let main(args) =
let t = sampleValue.Test //OK
let tt = sampleValue.Test2 //KO
Your assembly may be loaded into the different binding context. When quotation is deserialized it may try to load the assembly to the one binding context and this attempt may fail even if assembly was already loaded to another context. As workaround in your type provider design time assembly you can add handler to the AssemblyResolve event and try to find target assembly in the list of already loaded assemblies.
do System.AppDomain.CurrentDomain.add_AssemblyResolve(fun _ args ->
let name = System.Reflection.AssemblyName(args.Name)
let existingAssembly =
System.AppDomain.CurrentDomain.GetAssemblies()
|> Seq.tryFind(fun a -> System.Reflection.AssemblyName.ReferenceMatchesDefinition(name, a.GetName()))
match existingAssembly with
| Some a -> a
| None -> null
)
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.
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");
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.