Ghostscript installation issue on .net - c#

I followed a ton of SO guides in order to install Ghostscript in my MVC C# app but I cannot make the code below be recognized. It keeps saying "GhostscriptRasterizer could not be found (are you missing a using directive or an assembly reference?)"
public ActionResult PDFToImages(string pdfFilePath)
{
//...
using (var rasterizer = new GhostscriptRasterizer())
{
//...
}
//...
}
I am using Visual Studio and here's what I've already tried:
Get the .exe file from https://www.ghostscript.com/download.html and installed it. Then manually include gsdll32.dll in my project as "content" (menu: Add existing item);
On Visual Studio went to "Tools>NuGet Package Manager>Manage NuGet Packages for solution" and then installed Ghostscript.NET by Josip Habjan.
Also on NuGet Package Manager tried to install Ghostscript dlls by Matthieu - Get an error "Failed to add reference to 'gsdll32'. Please make sure that the file is accessible, and that it is a valid assembly or COM component."
On Package Manager Console did "Install-Package Ghostscript -Version 9.2.0" and got also the error above

If your objective is to make uso of Ghostscript .NET directly, you would not need to reference the original Ghostscript DLL from your project (as I said, until you desire to do so).
I tested Ghostscript .NET over Windows 7 and windows 10, with Visual Studio Community 2017 simply following these steps:
Install Ghostscript 9.52 for Windows (32 bits).
Using Nuget package manager, added Ghostscript .NET to my solution.
Include using code lines, as required (main namespace and Rasterizer for your case should work, I use Processor, in addition):
using Ghostscript.NET;
using Ghostscript.NET.Processor;
using Ghostscript.NET.Rasterizer;
I have checked in a new Console Application project the using clause (which makes use of Rasterizer class) that you have provided, and does not return any error, if I perform these steps previously.
Please, try again repeating the actions mentioned, and let me know if you manage to use Ghostscript that way.

Related

Unable to compile C# code on Mac

I am receiving an error when I try to compile my c# source code file on my Mac. Normally I compile my source code using the mcs command on a bash terminal window and it compiles fine. But, this one particular project requires the installation of the NuGet package 'MySql.Data'. This has resulted in the following error message:
error CS0246: The type or namespace name 'MySqlConnection' could not be found. Are you missing an assembly reference?
I have tried to follow numerous solutions online to try and add the assembly reference, but my IDE just does not look like the help documentation's screenshots.
I have tried to Edit References, but no references appear. I tried to manually download the MySql.Data.dll (v.6.3.5.0) but I think it is for an outdated version of the MySql.Data class library as it does not work. Even after cleaning the code and rebuilding it.
Edit: I have also tried to add the dll that was included in the project folder but it said it could not locate the assembly (even though they are both in the same project folder).
Could not resolve this reference. Could not locate the assembly "search_feature". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. (MSB3245) (search_feature)
Edit 2: I renamed the dll file from the project bin folder to MySql.Data.dll and I no longer get the error. But it still won't compile.
The code works fine when run in Visual Studios for Mac, but I just can't compile it. Any ideas how to add the assembly reference?
I am using the most up-to-date version of Visual Studios:
Visual Studios for Mac Community 7.5.4 (build 3)
I have tried uninstalling and reinstalling Visual Studios for Mac.
My code has the library reference at the top: Using MySql.Data.MySqlclient; and the project runs. It just won't compile.

Geany, Linux, C#, MySql.Data, NOT Visual Studio; the using statement doesn't compile

I just got C# working on Ubutnu. It's all good. But now I want MySql too. I installed the gacutil, and downloaded the connector, and I ran the gacutil, which it seemed like it worked.
I'm using Geany as my ide for now. It's free and already installed, and it worked great; until I tried to add using MySql.Data; I've read through all the stackoverflow posts for MySql.Data: they all state that I need to add an entry to my reference list in the VS project. Well, I don't have a reference list, nor a project. My 'project' directory only contains two(2) files: Test.cs, and Test.exe. MySql.Data is registered in the gac! Arg! Please, how do I get this working?!?!?
Running the gacutil:
dysmondad#Julep:/etc/mono/mysql/v4.5$ sudo gacutil -i MySql.Data.dll
Installed MySql.Data.dll into the gac (/usr/lib/mono/gac)
Complete source code for testing Mono install.
using System;
using System.Collections;
using System.Collections.Generic;
using MySql.Data; // <- this isn't recognized.
public class Test
{
static public void Main ()
{
List<int> integers = new List<int>();
integers.Add(7);
integers.Add(14);
integers.Add(21);
foreach( int i in integers )
{
Console.WriteLine(i);
}
}
}
UPDATE-1: Just found this on the MySql support page._______
You are now ready to compile your application. You must ensure that when you compile your application you include the Connector/Net component using the -r: command-line option. For example:
shell> gmcs -r:System.dll -r:System.Data.dll -r:MySql.Data.dll HelloWorld.cs
But...these don't work
-r:MySql.Data.dll
--nor--
-r:MySql.Data
UPDATE-2: I just discovered that if I use the -r option, and include the full path and name of the dll (even though it was registered with the gacutil) that seems to satisfy the compiler. So now my question is: how to get it to work with just the package name and not have to specify the full path?

c# project with CI build - reference to Oracle extension causes build error

I have a C# app build in MS VisualStudio (2015) and it's checked in to a VisualStudio repository hosted for the company I work for.
I defined a 'Build' profile on the VisualStudio server with 'Continuous Integration' on, so it builds every time there's a check in.
It's been working fine until now...
I had to add some code that called an Oracle Server, so in my code I have
OracleConnection conn = new OracleConnection(connString);
...
and at the top
using Oracle.ManagedDataAccess.Client;
and in my Project I did:
Add > Reference > Assemblies > Extensions > Oracle.ManagedDataAccess
so, it all builds and runs on my development PC.
On the TeamFoundationServer however, the build fails now with message
Error CS0246: The type or namespace name 'Oracle' could not be found (are you missing a using directive or an assembly reference?)
on the using line of the source file.
I assumed that the server would include the Oracle extension because it's now referenced in the project file (which is checked in). Is there another step I need to take?
The assemblies listed in the Extensions list are ones provided by extensions you've installed into Visual Studio (my guess is you've installed the 'Oracle Developer Tools for Visual Studio' extension).
Because this extension hasn't been installed on your build server (and nor should it) the build server naturally complains that it can't find the reference.
The solution is to remove the reference you've added an instead add a reference to the NuGet package containing the Oracle driver. This looks to be the correct one: https://www.nuget.org/packages/Oracle.ManagedDataAccess/
Your build server will then fetch the NuGet package as it would for any other assembly.

Tweetinvi namespaces are not recognized although dll's are present

I'm using creating a .Net 4.0 application to post stuff to Twitter using the Tweetinvi API. I can't use packages, so I've downloaded the dll's and added them to my project:
Yet my includes are showing errors:
My error console shows:
Error 423 The type or namespace name 'Core' does not exist in the
namespace 'Tweetinvi' (are you missing an assembly
reference?) {...file...}.cs 10 17 ApiProviders
Can anyone tell me why this happens and how I could fix this?
Tweetinvi requires the Bcl.Async package. You need to add that too.
Check all the dependencies and make shure all are installed.
BUT as already said I highly recommend using NuGet for this. If you are not allowed to use the "public feed" you can download the packages and put them in a local folder and add this folder as a new feed in Visual Studio.
Have you tried downloading the project from the download page?
https://tweetinvi.codeplex.com/downloads/get/852208

The type or namespace IAppBuilder could not be found(missing using a directive pr an assembly reference)

I am working on an Asp.Net MVC 4 Application in which I am using SignalR 2.0.1 and I Mapped it using Owin Startup class and it worked fine at first.
All of a sudden when I tried to rebuild my app it said that the type are namespace IAppbuilder could not be found.
Following is my start up class
using Microsoft.Owin;
using Owin;
using WhiteBoardApp;
namespace WhiteBoardApp
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
app.MapSignalR();
}
}
}
I have installed Owin package too, and for some reasons I could not find Owin Startup class so I just added a normal class and included all the references that are needed.
May I know where I am making a mistake
Try to use Package Manage Console and do
Update-Package Owin -Reinstall
I was having similar issue. But instead Owin, problem was causing Microsoft.Owin, obviously
Update-Package Owin -Reinstall
Didn't work, neither did Update-Package Owin
BUT
Install-Package Microsoft.Owin
did work fine for me, thanks.
The IAppBuilder interface is found under Owin package. Just add a reference in your class file:
using Owin;
And rebuild. Your project will pick this up.
I have no idea why VS didn't pick this up, but it didn't. Once I added this reference to my project, then everything fell into place.
I encountered the same problem while building my project. Here are the steps that helped fix my problem:
Go to Solution Explorer and look for your project
Under your project, expand the References; You should see warnings on the problematic reference
Right click References and open Manage NuGet Packages
Search the name of problematic reference i.e. Microsoft.Owin; After loading it shows that it is already installed (It is, but it installed incorrectly. Checking the properties > version at step 2 shows 0.0.0.0)
Check Force uninstall, even if there are dependencies on it
Uninstall
Install
Build and run the project
Problems
Cannot install Microsoft.Web.Infrastructure because it already exists in the packages folder. Rolling back...
Go to your project folder and look for packages
Find the problematic package i.e. Microsoft.Web.Infrastructure
Delete the folder
Resume from step 7
Alternatives
Here are the alternatives I've read about to fix this kind of problem.
Clean and Rebuild Project / Solution
Restart Visual Studio
Restart PC
Good luck.
My Visual Studio 2013 for some reason didn't realize that the references paths existed. The yellow exclamation mark in front of the references was shown for all the added packages. I checked ../packages/ but all files existed, i also opened the .csproj file which referenced the correct paths.
Closing and opening the solution returned quite a lot of errors, and could not load the projects included in the solution.
Restarting Visual Studio 2013 saved the day for some unexplained reason.
My following using's equivalent in F# present a problem of hiding the IAppBuilder. It turns out that the Owin stipulation was being interpreted as an incomplete System.Web.Http.Owin reference, even though the Owin.dll providing the Owin namespace was referenced.
open System.Net.Http
open System.Web.Http
open Microsoft.Owin
open Owin
The problem was resolved by rearranging the usings as follows:
open Microsoft.Owin
open Owin
open System.Net.Http
open System.Web.Http
...granted, this may be a bug peculiar to the F# compiler and name conflicts are handle better in C# and elsewhere.
In my case, I had moved around the project folders and the location of the vs solution file (.sln). Once I was done with re-adding the projects, there was a packages folder on the solution level and one was left in a project sub folder.
This way, in that project, the relative package folder links in the .csproj file got messed up.
The reinstallation or other tips regarding the nuget package manager in this thread were helpful. I noticed, that after I reinstalled a few packages, in my git source code diff, the path of the packages folder was changed within the csproj file.
Before
<HintPath>packages\Microsoft.Owin.4.0.1\lib\net45\Microsoft.Owin.dll</HintPath>
After
<HintPath>..\packages\Microsoft.Owin.4.0.1\lib\net45\Microsoft.Owin.dll</HintPath>
So, if you run in the same issue and you have a lot of nuget packages, it might be easier to close the whole solution, open the csproj file(s) in a text editor like vscode and fix the relative links with search and replace. Then just save, close, reopen solution in VS and restore nuget packages. That should do the trick.
(In any case, you should delete the local packages folder on the project level, so that the project really fails, if it does not get the right packages.)
It's an ordering issue.
using Microsoft.Owin;
using Owin;
Leads to Microsoft.Owin to be defined first, then Owin is found under already imported Microsoft namespace. If you mouse over Owin of using Owin you should see it was resolved to Microsoft.Owin again and furthermore IDE will gray out using Owin as redundant unused reference.
Do:
using global::Owin;
Which clarifies for the compiler not to look for Owin under already defined namespaces (e.g. Microsoft. namespace).
http://www.asp.net/signalr/overview/getting-started/tutorial-getting-started-with-signalr
Check for the visual studio you are using
You can find the following comment
Note: If you are using Visual Studio 2012, the SignalR Hub Class (v2) template will not be available. You can add a plain Class called ChatHub instead.
Also
Note: If you are using Visual Studio 2012, the OWIN Startup Class template will not be available. You can add a plain Class called Startup instead.

Categories

Resources