Compiling C# code with CSC - excel interop - c#

I am struggling with the following error when compiling my C# code with CSC - "error CS0234: The type or namespace name 'Core' does not exits in the namespace 'Microsoft.Office' (are you missing an assembly)"
I've had zero experience with object oriented programming before tackling this project. It involves automation of a couple devices through serial commands. Parameters are read from a native Excel file and data is written to Excel files that the code creates.
Here's what think maybe pertinent:
my compiling command: CSC /r:"C:\Data\Code\Microsoft.Office.Interop.Excel.dll" compiled.cs
I have the file Microsoft.Office.Interop.Excel.dll in the directory above. I found the file on my computer from something else that installed it. It is dated 2007.
I am using Office 2010
I installed Microsoft Office 2010: Primary Interop Assemblies Redistributable but can't tell what that did
I am referencing CSC from Framework (not Framework64) revision 4.0.30319
Here is the header to my code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO.Ports;
using System.Threading;
using Microsoft.Office.Core;
using Excel = Microsoft.Office.Interop.Excel;
using Microsoft.Office.Interop.Excel;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
Follow-up question (if I get this working) what things do I need to worry about to make this run on another computer? My thoughts was that all I needed was the .excel.dll and the .exe file in the same directory structure? (At this time I don't know what version of .NET or Office is being run on the target computer - my guess would be at least it would be Office 2010.)
Any guidance would be greatly appreciated. I've been wearing out google on this one for the past week+
Regards,
Keith

I know this is not the exact answer you're looking for, but I'm posting it because I think it would be more helpful than directly answering your question.
You would save yourself a LOT of time by downloading Visual C# 2010 Express and letting the IDE do the heavy lifting for you.
It sounds like you need to add a reference, which means referencing an existing .dll file somewhere. I know if can be done via the command line, but it's a LOT easier to use the IDE.
It's free, and can be found here: http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-csharp-express
There's a How-To guide for Office Interop here: http://msdn.microsoft.com/en-us/library/dd264733.aspx

Related

Saving a Crystal Report as a PDF within a c# class

Newbie question. I'm trying to write a c# class that can run a Crystal Report and save the result as a PDF file. My method currently only contains one line, which it is failing on:
ReportDocument reportDocument = new ReportDocument();
My "using" list contains:
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
I've installed two NuGet packages, CrystalDecisions.CrystalReports.Engine and CrystalDecisions.Shared. I'm just trying to follow some examples I've found from web surfing, and it seems that the examples I'm looking at always include these two packages.
The error I'm receiving on the ReportDocument instantiation above is:
"Could not load file or assembly 'CrystalDecisions.ReportAppServer.ClientDoc, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304'. The system cannot find the file specified."
I suspect there's something obvious I'm missing that hasn't been installed. I do have Crystal Reports 2011, SAP Crystal Reports runtime engine for .NET Framework (32-bit), and Crystal Reports 2008 Runtime SP2 installed on my machine. I'm new to a lot of this and am not having much success finding the help I'm looking for.
Help is greatly appreciated. Thank you!
Please try this : first create instance of Crystal report, and you can simply Call Export To disk
RtpDocument.ExportToDisk(ExportFormatType.PortableDocFormat, "C:\report.pdf")

Namespace NPOI.POIFS.Crypt

I installed NPOI from NuGet, version 2.1.3. I want to read encrypted excel file. By this goal according to this thread i need use class EncryptionInfo from namespace NPOI.POIFS.Crypt. But my assembly not contain this namespace.
If you look at the GitHub repository for this library, you will see this namespace in version 2.1.3.
What is my error?
P.S. Sorry for my english language

Windows Store Project - Assembly reference error when trying to run cmd commands from a C# file in VS2012

I'm doing some exercises with C# in the trial version of VS 2012. I want to execute a cmd command from a CS file. For this, I've tried Process.Start as well as System.Diagnostics.Process that are mentioned in these posts:
Run Command Prompt Commands
Execute CMD command from code
However, despite I added "using System.Diagnostics" and "using System.ComponentModel", I'm still getting "The type or namespace name 'Process' does not exist in the namespace 'System.Diagnostics', missing assembly reference" error. ¿Any suggestion so I can i get rid of this error? Thanks in advance.
This usually happens when you have Target framework = .NET Framework Client Profile, but DLL you reference is from .NET Framework (full). Make sure you have System.dll in your references from valid framework.
I just did the same - created empty console application with the following code:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.ComponentModel;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
var prc = Process.Start("explorer.exe");
}
}
}
Works perfectly fine for me.
Additional thing to check is Intellisense - when you start typing "System.Diagnostics.Proc"... - does it show you dropdown with "Process" there?
UPDATE:
Windows Store projects are based on different version of target .NET Framework - .NET for Windows Store apps, which does not support functionality you need.
For more details do web search:".NET for Windows Store apps". Helpful links:
http://msdn.microsoft.com/en-us/library/windows/apps/br230302.aspx
http://msdn.microsoft.com/en-us/library/windows/apps/br230232.aspx

Using Thrift and Apache.Cassandra in Visual Studio

I'd like to connect to Cassandra (already running on localhost) from C# (with Visual Studio IDE) using the "Thrift" and the "Apache.Cassandra" resources.
The first question is... shall I use a client like "cassandra-sharp" or the resources previously mentioned? I found an example (http://www.ridgway.co.za/archive/2009/11/06/net-developers-guide-to-getting-started-with-cassandra.aspx) using those resources and it seems easy to me.
And the second (stupid) question is: how can I external resources in Visual Studio? I installed NuGet and I downloaded Thrift (still looking for "Apache.Cassandra"), now it's placed in the "References" directory and I wrote "using Thrift.Protocol", etc in declarations...
but when I try to debug I get some errors like:
"The type or namespace name 'TTransport' could not be found (are you missing a using directive or an assembly reference?)"
Thank you all for the help,
Lorenzo
Get one of available clients for C# first, then learn if you need to build your own.
If you decide you'd like to build your own client (including connection pooling), you need to download from http://thrift.apache.org/download/ Thrift C# library sources (currently v.0.8) to include into your project, an msbuild task or Thrift.exe compiler to build C# Cassandra proxy sources/library from cassandra.thrift.

Cannot create Python Object in .NET with IronPython

Newly I started working with IronPython in .NET but as I saw some few examples they're making engine with Python.CreateEngine() But the Python object isn't loaded for me however I imported these references.
using IronPython.Hosting;
using IronPython.Runtime;
using Microsoft.Scripting;
using Microsoft.Scripting.Hosting;
I searched around this topic but I couldn't find anything.
Peace Out!
Bit of a tangent, but by far the quickest way of getting going with IronPython is to download a copy of SharpDevelop and use a project template to start you off. You'll sidestep a lot of these initial environment issues.
Did you actually add the assemblies to your project?

Categories

Resources