Excel Type Provider has error - it needs an assembly "Excel.dll" - excel

So, I started with this code:
open System
open System.IO
open FSharpx
open Excel
module ExcelManipulation =
type BoyICantWaitToUseThis = ExcelFile< #"C:\Users\sean.newham\Documents", "Sheet1", true>
let example = new BoyICantWaitToUseThis()
...but it doesn't compile because I need an "Excel.dell, Version=2.1.0.0...", I didn't know which Excel.dll that was, so I tried including the Excel Data Reader, which has a dll called "Excel.dll", but alas, this does not appear to have removed the error message.
Any idea what I need here and where I could get it from?
Thanks in advance

It appears that until about 5 days ago (see here), the excel type provider had a dependency on having Office installed with the office interop files. The newer version depends on the Excel Data Reader.
If you look at the pull request for that change here, you see that the type provider used to reference
<Reference Include="Microsoft.Office.Interop.Excel, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
See here for instructions on how to install that.
As an added bonus, you can look at the unit tests in that link for details on how to use the provider.

I was stuck at this same point trying to use FSharpx.TypeProviders.Excel. I switched to ExcelProvider and it worked out-of-the-nuget-box:
http://fsprojects.github.io/ExcelProvider/

Related

ExcelProvider is not defined - how resolve this error?

I am trying to get a type provider working with Excel. This is my first time and I am having trouble. I downloaded FsharpX.ExcelProvider from Nuget.
Here is my code:
namespace xxxx
open System
open System.IO
open FSharpx.TypeProviders
type TimesheetRow = ExcelProvider<"C:\SourceModules\MyFile.xlsm","Timesheet",true>
The problem is that there are red squigglies under ExcelProvider, and the fly-over message is ExcelProvider is not define
Can someone help me know what I need to do here to resolve this problem?
Possibly pertinent: Visual Studio 2013 with Office 2010 installed.
I am still trying stuff as I wait for answers. When I type in the full name, FSharpx.TypeProviders. intellisense gives me the choice of ExcelProvider. So it is there.
What John Palmer said: What are your references?
That is, if its not there already; add the package ExcelDataReader, and possibly the world looks much better...
https://www.nuget.org/packages/ExcelDataReader/

Error Running Code Analysis in VS2012: Could not resolve type reference

When I click the Run Code Analysis project context menu item. Building starts, but stops with following error:
CA0001 Error Running Code Analysis
CA0001 : The following error was encountered while reading module 'EntityFramework':
Could not resolve type reference:
[System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35]System.ComponentModel.DataAnnotations.Schema.ColumnAttribute. [Errors and Warnings] (Global)
Analysis on other projects works well. How to eliminate this problem?
I tried the solution mentioned by Scott Wylie. I tried adding a reference to System.ComponentModel.DataAnnotations in my project but that did not help.
I then tried copying and pasting the System.ComponentModel.DataAnnotations.dll directly into my bin folder and that did the trick. Add the dll into your local bin folder, publish the solution, then manually add the dll into the bin folder of your published project (if it didn't copy up on its own).
The System.ComponentModel.DataAnnotations dll may not be used by your application but it is internally referenced by EntityFramework.dll. Code Analysis will look at all of your referenced dll's and try to resolve their references too. If you add the System.ComponentModel.DataAnnotations.dll to your application, this error will go away next time you run Code Analysis.

got subsonic compile error

I use visual studio 2010 and tried to use subsonic and i am getting the following error.
Error 2 Compiling transformation: Metadata file 'MySql.Data' could not be found D:\TradingTools\CODE\ConsoleApplication8\subsoniccomponents\Structs.tt 1 1 backtester
As you can see from the screenshot, i do have mysql.data in my references. i dunno how to fix this. Can you help fixing this problem.
http://postimage.org/image/s1es0mr79/
SubSonic uses the DbProviderFactory pattern.
The DbProviderFactory approach allows the creation of Connections/Commands/... without knowning the concrete type.
// without factory
var con = new MySqlConnection();
var cmd = new MySqlCommand();
// with factory
var factory = DbProviderFactories.GetFactory("MySql.Data.MySqlClient");
var con = factory.CreateConnection();
var cmd = factory.CreateCommand();
which is a way more generic approach.
However, in order for this to work, you have to install MySql.Data (the msi-Package) which makes some entries in the machine.config file.
That said,
I also prefer my build environment not to rely on installed software, which makes it a lot easier to switch to a new machine without installing multiple dependencies.
But this requires a little bit work:
Modify your app.config/web.config file and place this somewhere between <configuration> and </configuration>
<system.data>
<DbProviderFactories>
<remove invariant="MySql.Data.MySqlClient"/>
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient"
description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.4.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories>
</system.data>
I just copied and pasted the snippet from
%windir%\Microsoft.NET\Framework\<version>\Config
after installing the MSI.
If your solution has multiple projects, you have to do this for the main project (so subsonic can find your provider at runtime) and in your DAL project (so subsonic can find your provider during code generation).
If you use another MySQL Version you can change that.
The second thing you have to do is to tell the templates where to find the MySql.Data.dll (if it is not in the GAC).
You can do this by editing the MySQL.ttinclude file (look at the assembly directive)
<## include file="Settings.ttinclude" #>
<## assembly name="$(SolutionDir)\Dependencies\MySql.Data.dll" #>
<## import namespace="MySql.Data.MySqlClient" #>
<#+
With these changes my solution runs find and template generation also works find on a clean install without any MySql Components installed.

Error while compiling a library in C#

I am trying to compile a class(sqlAccess) declared as public with few methods related to database connection in it. I am getting the following error ...
Error 1 Friend access was granted to 'SqlAccess, PublicKey=00c8', but the output assembly is named 'SQLAccess, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Try adding a reference to 'SqlAccess, PublicKey=00c8' or changing the output assembly name to match. c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Data.dll SQLAccess
What could be the reason? is there already a method of that name? I am new to programming so am unable to understand this clearly. Thank you.
This worked for me:
Open the Properties|Signing Tab. Ensure that you have "Sign the Assembly" checked and the strong name key file referenced. Save and compile the Project/Solution.
(cited from MSDN)
.NET seems to get grumpy if you give your assembly/project a name that isn't unique. In your case, SqlAccess must already exist in .NET or a referenced assembly.
The fix is to rename your assembly.
Similar issue:
Weird error in C#
That's because SqlAccess assembly has a reference which granted internal access to SqlAccess. It must be something like this [you will find it in AssemblyInfo.cs] :
[assembly: InternalsVisibleTo("Name of assembly goes here, PublicKey=")]
During compile time when compiler can not find assembly with specific PublicKey, you will get the error such as 'Friend access was granted to...'.
In order to resolve this problem one solution is to remove above attribute from source assembly, or add new public key and change it in source assembly.
Reason behind this should be either you have reinstall/update that particular dll within your solution and but old dll was not deleted properly from your solution and system.
That's why, it got worked when you change the Assembly name (from sqlAccess to sqlAccessXYZ)
I changed the Assembly name to sqlAccessXYZ and now its working, the problem is with the name. Not sure what exactly the problem, for now the issue is resolved. Thanks.

How can I use classes from VisualBasic-Express in VBA for Excel or Access projects?

I saved my VB-Express code as .dll and registered it with regasm and made a .tlb file.
But when I try to run a function from it in an Excel-modul I get: Run-time error ‘453’: Can’t find DLL entry point RegisterServiceProcess in kernel32
What step did I miss?
See http://richnewman.wordpress.com/2007/04/15/a-beginner’s-guide-to-calling-a-net-library-from-excel/
or better still try out ExcelDNA ( http://groups.google.com/group/ExcelDna )
I think you're creating a .Net dll and trying to call it from a COM-oriented environment (VBA), which isn't going to work without help. If I'm guessing right, then you need to investigate the COM Interop elements of .Net: Google throws up lots of promising-looking links, one of which is this article.
It looks a bit unpleasant, but I expect the nastiness can be tucked away somewhere...
Try this Microsoft Knowledge Base article: Can't Run Macro That Calls 16-bit DLL in 32-bit MS Excel.
Do you have the proper rights to access the DLL?
Thanks for the input to everybody, you helped me a big step further.
After following the guides you provided I got: Run-time error: '-2147024894' (80070002)': File or assembly name AssemblyName, or one of its dependencies, was not found.
But I could fix that with this Workaround.

Resources