Open another Project C# - c#

I have a Solution that has a windows forms project in it. I have added a Word Document to it so that I could use this for a reporting tool. It seems that I have run into some problems while trying to open this.
I found this, which helped me out a lot but now when I try to use the code below, I'm getting an error message that tells me "ThisDocument does not contain a constructor that take 0 arguments."
wrd.Application wrdApp = new wrd.Application();
ThisDocument doc = new ThisDocument();
So I look at the tool tips and they say "Mircosoft.Office.Tools.Word.Factory, IServiceProvider". Can someone explain what these are?

Related

C# BadImageFormatException when saving data using Microsoft.Xna.Framework.Content.Pipeline

First question on here and I am feeling pretty stumped, I've searched around but couldn't find something that I could apply to my situations, any help or direction to a prior question would be appreciated.
I'm receiving an error when trying to create some new files from my form. I'm following a guide at XNA Game Programming Academy (xnagpa_net/xna4rpg_php), I'm up to step 14 but I believe this started happening earlier and I hadn't noticed it yet.
Screenshot of Error
Please have a look at the above error and give me any tips.
My code for RpgEditor.FormMain.cs is here, it says something about line 128 which relates to;
if (Directory.Exists(gamePath))
throw new Exception("Selected directory already exists.");
I'm not sure why though, because I'm creating a brand new folder/directory when I am attempting to save the data.
If it helps, the subdirectories are being created by the process but I recieve that error and no files inside.
edit: I've downloaded the example project on his site and it's working fine with that, so I don't believe it's an issue with my system configuration.. must be a project setting or line of code somewhere..
To fix this I had to change the configuration settings.
It was set to AnyCPU but I had to change to x86.
The setting wasn't there originally, I had to create new and copy settings from AnyCPU.
Why this works I don't know, but it does :)

Not able to Convert .dwg to .pdf using .Net and True View (AcCtrl)

What I am trying to do is:
I have a Asp Mvc website. In it I need to create a function that does the following:
converts a .dwg (AutoCad) file to a .pdf file
converts a .dwg file to a .dwf file
I started with the, what I tought at the time, easier task to have the .dwg to a .pdf. After some research I found out that a way to do that (without buying a 3rd party license) is to install TrueView on the server and using it (or actually a AcCtrl.dll) to convert the file. Well, I did so. I installed the True View program and added a reference to AcCtrl Component (ACCTRLLib). Then I added a reference to the Dll inside the class file I am working on:
using ACCTRLLib;
So far so good. After that I followed the instructions on this post: PDF conversion using dwg true viewer in VB6
First, this is my code:
public static void ConvertFile()
{
IAcCtrl contrl = new AcCtrl();
contrl.PutSourcePath(#"D:\MMA\Autocat\File1.dwg");
string[] pdfPath = new string[1] { #"D:\MMA\Autocat\File1.dwg" };
contrl.SilentPublish(pdfPath);
}
Then, according to the post, I went to see if there is a registry with the specified path. The path that I have as a registry is the following:
HKEY_CURRENT_USER\Software\Autodesk\DWG TrueView\R13\DWGVIEWR-E001:409\Profiles\<<\Unnamed Profile>>\Dialogs\AcPublishDlg
So, I created a 'String Value' in it with ValueName: Location and ValueData: D:\MMA\Autocat\Testing
Alright. So, thats it. After all that I ran the application and called the function. The debugger goes through the code and everything executes (or at least looks like so) but nothing happens. I don't get a file in the D:\MMA\Autocat\Testing folder. I get no exception, no warning nothing. It just executes and nothing happens.
So what else did I tried. Some of those things might be a little naive or silly to try but nevertheless I did as I happen to be a little desperate.
I tried everything in a console application. I wasnt completely sure that this method is suitable for ASP MVC so I tried the same code with a console application unfortunatelly to the same result.
I added a file name inside the location string value. I changed the Location ValueData from 'D:\MMA\Autocat\Testing' to 'D:\MMA\Autocat\Testing\testFile.pdf' as I noticed that nowhere in the whole process a file name is asked for the converted file.
Following my thought from the previous conclusion I tried to supply the path to the 'result' file to the SilentPublish function.
string[] pdfPath = new string[1] { #"D:\MMA\Autocat\Testing\testFile.pdf" };
contrl.SilentPublish(pdfPath);
Again to no avail. So, my question, or rather questions are:
Is it possible to do it this way and if it is what am I doing wrong?
If its not than can you suggest a way?
Also if a .dwg to .dwf conversion is possible (with the same or different method I am all ears)
Thank you very much
True View does not expose the Autodesk.AutoCAD.PlottingServices namespace. You're going to need either a licensed copy of AutoCAD, RealDWG, or another third party API.
I'm not sure if you are still having this issue, but you should be able to do this with the Autodesk Forge API. Calls can be made from any language with a simple HTTP call. You will have to first convert to SVF and then to DXF and PDF from there.

video frames extraction code running error

i found an article on this site http://www.codeproject.com/Articles/9676/Extracting-still-pictures-from-movie-files-with-C
about video frames extraction.
i am trying to run the source code given here..
i created a new project added the given C# code in it.
then i added the given reference " interop.dexterlib.dll" in it.
it gives an error about MediaDetClass.
Error 1
Interop type 'DexterLib.MediaDetClass' cannot be embedded. Use the applicable interface instead.
i am not getting it how to solve this. please help.

Visio Interop Questions

I have written a console application which uses UDC (universal document convertor) to convert visio diagrams to an image (more specifically a jpeg).
Everything is working fine (for visio files in 2007 and 2010), and I am using Microsoft.Office.Interop.Visio version 14.0.0.0. I thought I would do a test by creating a visio diagram in Visio 2003 and testing the application. It works fine however, I get the following popup "The Microsoft Visio building plan shapes in this drawing must be updated to function in the current version of Visio". If I click "Yes" then the program works fine. This code will eventually be running as a service and I was wondering if there is anyway to supress these warnings? Or tell it to do any conversion automatically?
We seem to have found the answer (trying nearly every property on the Visio.Application class!):
vApp = new Microsoft.Office.Interop.Visio.Application();
vApp.Visible = false;
vApp.Settings.ShowFileOpenWarnings = false;
vApp.EventsEnabled = 0;
It seems the EventsEnabled = 0 did the trick!
Hope this may be useful to someone eventually.. I spent about 4 hours on it :)
You can set vApp.AlertResponse = vbYes, which suppresses the dialog and chooses Yes for you.

Import to Excel does not work

I am using the Office Integration Pack
After following instruction correctly I am still not able to get the Excel to Import working
My Visual Studio Lightswitch 2011 application is configured to host on IIS Server and use's Easy Shell (so its the default Shell provided by MS).
So far I have tried is calling the
OfficeIntegration.Excel.Import(
this.States,
#"C:\Users\Mr_Mia_Gie\My Documents\ExcelSheet.xls",
"Sheet1",
"A1:C3");
on _Execute event of a button (the button does not live on the Shell Command Bar)
The exception I get back is "Object variable or With block variable not set."
Any solution or suggestion will be highly appreciated
Cheers
I agree with Nevyn (& I'd vote up his answer, but it's embedded in the question as an edit so I can't).
As Nevyn has pointed out, there are really only three objects in that particular line of code that can be causing a null exception:
the OfficeIntegration object
the OfficeIntegration.Excel object
or, the this.States collection (unlikely though)
As was also pointed out for you, it's most likely that one of those objects isn't correctly initialised. You need to check what the value of those three objects are by putting a break point on that line & checking what their values actually are at that point.
You could also put a guard clause in your code (just above that line):
if (OfficeIntegration == null) || (OfficeIntegration.Excel == null) return;
It won't neccesarily "fix" the problem, but it will stop the null exception from occuring (but this shouldn't be a problem in an Execute method). But it's good programing practice to put a guard clause any time you're referencing an object whose value could be null.
Failing that, the only other advice any of us can give you is to post a question in the questions section of the gallery page, where you downloaded the extension from. The autor of the extension should be able to help you.
Is this a web application, if so I dont think it supports it. It requires an extenstion. I dug up an article for you, try it out:
http://blogs.msdn.com/b/lightswitch/archive/2011/04/13/how-to-import-data-from-excel.aspx
The office integration Pack is for Visual Studio LightSwitch windows application and does work for application that are hosted on IIS hence the below code throws exception
OfficeIntegration.Excel.Import(
this.States,
#"C:\Users\Mr_Mia_Gie\My Documents\ExcelSheet.xls",
"Sheet1",
"A1:C3");
The link show that the extension does not support LS WebBrowser application http://officeintegration.codeplex.com/discussions/374585
Also the extension Import data from Excel does work for IIS hosted LS application that runs in webbrowser

Categories