Getting an error when trying to call LocalReport.Render("EXCELOPENXML") - c#-4.0

I have installed DocumentFormat.OpenXml (ver 2.5.5631.0) from nugetpackage manager in VS2010. I can see the reference to the DLL. I have created a package folder. But when I am trying to execute method:
public override void Render(LocalReport report)
{
this.SetUpParameters(report);
byte[] renderedReport = report.Render("EXCELOPENXML");
this.target.UpdateRenderedReportContent(renderedReport);
}
I am getting this error:
Specified argument was out of the range of valid values. Parameter name: format
When I am using
report.Render("EXCEL");
I am not getting any error. I have to use EXCELOPENXML to generate xlsx excel.

What version of Microsoft.ReportViewer.WinForms are you referencing? If it's less than 11.0, that's probably your problem.
Incidentally, Visual Studio (2013) declined to show me version 11.0 as an option from the Add Reference dialog. I don't understand why. I had to browse to the the assembly in the GAC:
C:\Windows\assembly\GAC_MSIL\Microsoft.ReportViewer.WinForms\11.0.0.0__89845dcd8080cc91\Microsoft.ReportViewer.WinForms.DLL
Once you do that, run the following method. You should see EXCELOPENXML as an option now.
new LocalReport().ListRenderingExtensions();

Related

How to create a COM visible dll in F#

My aim is to create a COM Visible Type that can be imported into VBA (Excel) and consumed there.
The Excel Object Browser can see my class but not any public methods of the class and fails on the attempt at calling a public method.
My F# Code:
namespace DotNetLibrary
type public Class1() =
member public this.DotNetMethod (x:string) = "Hello" + x
In the AssemblyInfo.fs I also amend to [<assembly: ComVisible(true)>]
I run regasm with switches of /codebase /tlb and a .tlb file is generated.
VBA finds my library in the references browser but does not pick up the DotNetMethod defined on Class1 above.
I have tried to follow the C# guidance for this topic in getting to where I am at the moment but I'm not getting to the finish line.
Run-Time Errors
The reason that VBA could not run the method succesfully is because I used the 32-bit version of the regasm utility instead of the 64-bit version to register the type library for COM. Given that I am using 64-bit Excel it needed 64-bit COM type libraries.
Compile-Time Issues
The reason that VBA could not identify the methods in the IDE could be related to the above, but is also likely to be due to the interface issues raised by
#HansPassant in his comments above.

The namespace "TypeProviders" is not defined (open Microsoft.FSharp.Data.TypeProviders)

I'm walking through Visual Studio's F# tutorial project. When I uncomment the "OData" module (which is very simple, similar to this MSDN walkthrough), the first line here
open Microsoft.FSharp.Data.TypeProviders
type Northwind = ODataService<"http://services.odata.org/Northwind/Northwind.svc/">
// ...
indicates this compiler error:
The namespace "TypeProviders" is not defined
The error remains after adding a reference to "FSharp.Data.TypeProviders" and "System.Data.Services.Client".
What am I doing wrong here?
Okay, you need to create new project, then add FSharp.Data.TypeProviers nuget to this project and the following code should work:
open Microsoft.FSharp.Data.TypeProviders
type Northwind = ODataService<"http://services.odata.org/Northwind/Northwind.svc/">

Typescript giving "Output Generation Failed" in Visual Studio 2012 with 0.9.5

I've been using Typescript 0.9.5 for the last few days, and then suddenly today the JavaScript files just stopped being generated. I see an error "Output generation failed" in the Visual Studio status bar, but nothing in any of the output windows.
I've rebooted, and restarted Visual Studio, disabled Web Essentials, tried all the usual things.
The files are set as TypescriptCompile in the properties. I've tried adding new files, or editing old ones with no effect. The Project file hasn't been changed as far as I can tell (its in TFS and none of the TypeScript sections have been altered).
I've made sure both files are checked out, still nothing.
Update: I've managed to compile manually using tsc.exe from the command line, so it must be something in Visual Studio.
OK, so I solved the problem.
One of my files contained invalid typescript, specifically trying to export a class when not inside a module. This caused all typescript files to fail to generate, but with no useful error message.
The following file would cause the problem:
export class Test {
public DoSomething() {
}
}
Either removing the export keyword, or adding a wrapping module solved the problem.
I've raised it as an issue here: https://typescript.codeplex.com/workitem/2109
Update: More details.
The above syntax is valid if you are using the CommonJS or AMD module patterns.
To enable this in visual studio you need to edit the .csproj file and insert a new PropertyGroup:
<TypeScriptModuleKind>AMD</TypeScriptModuleKind>
If you have an export outside of an internal module Typescript tries to compile it as either commonjs or amd module format. The compilation will fail if the a --module flag is not present on the command line. Use your project properties to set it to the desired value (probably amd in your case).
More info on TypeScript modules : http://www.youtube.com/watch?v=KDrWLMUY0R0&hd=1

Obfuscation failed in j2me

I tried to obfuscate my project in j2me..But it is showing the following error.I came to know that this obfuscation error happened only when i importing Json.jar in my project..If i remove this jar means obfuscation is happening..Please help me solve this..Thanks in advance.
Warning: org.json.me.JSONArray: can't find referenced method 'java.lang.Object remove(int)' in class java.util.Vector
Warning: there were 1 unresolved references to program class members.
Your input classes appear to be inconsistent.
You may need to recompile them and try again.
Alternatively, you may have to specify the options
'-dontskipnonpubliclibraryclasses' and/or
'-dontskipnonpubliclibraryclassmembers'.
Error: Please correct the above warnings first.
C:\Users\Ponmani\Documents\TThehinduNov22ponmani\nbproject\build-impl.xml:427: Obfuscation failed with error code 1.
BUILD FAILED (total time: 4 seconds)
This error happens because the JSONArray class uses remove(int) method from Vector class, but this method is not available for Java ME: http://docs.oracle.com/javame/config/cldc/ref-impl/midp2.0/jsr118/java/util/Vector.html
You picked a Java Se version of the library. Please, try this other library: https://github.com/upictec/org.json.me/
Update
There is a ZIP button where you can download the repository as a zip file.
Inside the zip file enter /src/main/java.
Copy org folder and paste it in your src folder.

Asssembly.LoadFrom fails when called via Excel 2007

I have a .NET 4.0 class that uses Assembly.LoadFrom to load a .NET 3.5 mixed mode assembly. When this class is called from a .NET 4.0 app (with useLegacyV2RuntimeActivationPolicy="true" specified in the config file) it all works fine.
However, this class is also COM visible, and when I then call it from Excel 2007 (again, Excel.exe.config specifies useLegacyV2RuntimeActivationPolicy="true") I get a FileLoadException:
Could not load file or assembly 'Foo...' or one of its dependencies. Failed to load the runtime. (Exception from HRESULT: 0x80131700)
The inner exception is a System.Runtime.InteropServices.COMException: Failed to load the runtime. (Exception from HRESULT: 0x80131700)
I do not get this problem when calling from Excel 2003 or Excel 2010 or vbscript. Can someone explain what is going on and how I can fix it?
I've discovered from Microsoft that this is a known issue with Excel 2007. The problem has been resolved in Excel 2010, and the issue will not be fixed in Excel 2007.
The workaround is to force Excel to use a COM-exposed .NET 2.0 type before using the .NET 4.0 class. I did this by adding a reference to the .NET 2.0 version of mscorlib.tlb, and then adding the following VBA code before calling the .NET 4.0 class:
Dim o as mscorlib.Object
Set o = New mscorlib.Object
Hope this proves useful to anyone who stumbles across this obscure issue!

Resources