`I have added COM reference in my project i.e(MODI) for converting image to text .
while creating docker build for creating image in terminal i am getting below error.
/app/Services/ConvertPdftoWord.cs(18,37): error CS0246: The type or namespace name 'MODI' could not be found (are you missing a using directive or an assembly reference?) [/app/ModiOcr.csproj]
Even while adding COM reference it automatically .csproj file added below line
<ItemGroup>
<COMReference Include="MODI" Condition="'$(MSBuildRuntimeType)' != 'Core'">
<WrapperTool>tlbimp</WrapperTool>
<VersionMinor>0</VersionMinor>
<VersionMajor>12</VersionMajor>
<Guid>a5ededf4-2bbc-45f3-822b-e60c278a1a79</Guid>
<Lcid>0</Lcid>
<Isolated>false</Isolated>
<EmbedInteropTypes>true</EmbedInteropTypes>
</COMReference>
</ItemGroup>
Dockerfile i have attached and i am new to Docker Please help on this.
`
how to resolve this issue do i need to include COM referene into Dockerfile?
Related
Im using VS2022 to create a .NET Core 3.1 C# class library (DeletemeClassLib.csproj) with no added content. Solution and Project are in the same folder. This builds as expected.
When I add a MSTest project to the existing solution using .NET Core 3.1, the MSTest project will build without errors, but the DeletemeClassLib.csproj build fails with errors like:
Error CS0246 The type or namespace name 'TestClass' could not be found (are you missing a using directive or an assembly reference?) DeletemeClassLib C:\Users...\VSProjects\DeletemeClassLib\MSUnitTests1\UnitTest1.cs 5 Active
The build errors appear to point to my UnitTest1.cs file (in the MSUnitTest.csproj project), but they only occur when building the separate DeletemClassLib.cs project. I also tried the same thing using nunit instead of MSTest, but I found similar results.
My DeletemeClassLib.csproj has no packages listed under the project. My MSUnitTest1 project lists coverlet.collector 1.2.0, Microsoft.NET.Test.Sdk 16.5.0, MSTest.TestAdapter 2.1.0, and MSTest.TestFramework 2.1.0.
DeletemeClassLib.csproj
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<PlatformTarget>x64</PlatformTarget>
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
</PropertyGroup>
</Project>
MSUnitTests1.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.1.0" />
<PackageReference Include="MSTest.TestFramework" Version="2.1.0" />
<PackageReference Include="coverlet.collector" Version="1.2.0" />
</ItemGroup>
</Project>
Class1.cs (main project file in DeletemeClassLib.cs project):
using System;
namespace DeletemeClassLib
{
public class Class1
{
}
}
MSUnitTest1.cs (Main MSTest unit test file):
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace MSUnitTests1
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
}
}
}
Build Output with username hidden:
1>------ Build started: Project: DeletemeClassLib, Configuration: Debug Any CPU ------
1>C:\Users\XXXXUser\VSProjects\DeletemeClassLib\obj\Debug\netcoreapp3.1\DeletemeClassLib.AssemblyInfo.cs(14,12,14,54): error CS0579: Duplicate 'System.Reflection.AssemblyCompanyAttribute' attribute
1>C:\Users\XXXXUser\VSProjects\DeletemeClassLib\obj\Debug\netcoreapp3.1\DeletemeClassLib.AssemblyInfo.cs(15,12,15,60): error CS0579: Duplicate 'System.Reflection.AssemblyConfigurationAttribute' attribute
1>C:\Users\XXXXUser\VSProjects\DeletemeClassLib\obj\Debug\netcoreapp3.1\DeletemeClassLib.AssemblyInfo.cs(16,12,16,58): error CS0579: Duplicate 'System.Reflection.AssemblyFileVersionAttribute' attribute
1>C:\Users\XXXXUser\VSProjects\DeletemeClassLib\obj\Debug\netcoreapp3.1\DeletemeClassLib.AssemblyInfo.cs(17,12,17,67): error CS0579: Duplicate 'System.Reflection.AssemblyInformationalVersionAttribute' attribute
1>C:\Users\XXXXUser\VSProjects\DeletemeClassLib\obj\Debug\netcoreapp3.1\DeletemeClassLib.AssemblyInfo.cs(18,12,18,54): error CS0579: Duplicate 'System.Reflection.AssemblyProductAttribute' attribute
1>C:\Users\XXXXUser\VSProjects\DeletemeClassLib\obj\Debug\netcoreapp3.1\DeletemeClassLib.AssemblyInfo.cs(19,12,19,52): error CS0579: Duplicate 'System.Reflection.AssemblyTitleAttribute' attribute
1>C:\Users\XXXXUser\VSProjects\DeletemeClassLib\obj\Debug\netcoreapp3.1\DeletemeClassLib.AssemblyInfo.cs(20,12,20,54): error CS0579: Duplicate 'System.Reflection.AssemblyVersionAttribute' attribute
1>C:\Users\XXXXUser\VSProjects\DeletemeClassLib\MSUnitTests1\UnitTest1.cs(1,17,1,29): error CS0234: The type or namespace name 'VisualStudio' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
1>C:\Users\XXXXUser\VSProjects\DeletemeClassLib\MSUnitTests1\UnitTest1.cs(5,6,5,15): error CS0246: The type or namespace name 'TestClassAttribute' could not be found (are you missing a using directive or an assembly reference?)
1>C:\Users\XXXXUser\VSProjects\DeletemeClassLib\MSUnitTests1\UnitTest1.cs(5,6,5,15): error CS0246: The type or namespace name 'TestClass' could not be found (are you missing a using directive or an assembly reference?)
1>C:\Users\XXXXUser\VSProjects\DeletemeClassLib\MSUnitTests1\UnitTest1.cs(8,10,8,20): error CS0246: The type or namespace name 'TestMethodAttribute' could not be found (are you missing a using directive or an assembly reference?)
1>C:\Users\XXXXUser\VSProjects\DeletemeClassLib\MSUnitTests1\UnitTest1.cs(8,10,8,20): error CS0246: The type or namespace name 'TestMethod' could not be found (are you missing a using directive or an assembly reference?)
1>Done building project "DeletemeClassLib.csproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========
Any ideas on what might cause the DeletemeClassLib.csproj build to fail when the MSUnitTest1.csproj is present?
If I move MSUnitTest1.csproj to a completely separate folder, everything builds correctly. However, I am trying to retrofit an older Github solution (this example is a simple representation of the other project) to add unit tests, and I can't add a unit test folder above the git parent to separate the unit tests and main project into separate folders as I would like to.
Thanks
Using csc how can I reference another project's source?
If I have my own .csproj for a hefty project that depends on another, and am compiling the dependent with dotnet build rather than csc I can add
<ItemGroup>
<ProjectReference Include="..\MyAPI\MyAPI.csproj" />
</ItemGroup>
To the csproj file, but what about in the case of writing a single .cs file?
csc test.cs /reference:../MyAPI/MyAPI.csproj
doesn't work because
error CS0009: Metadata file '/Users/theonlygusti/MyAPI/MyAPI.csproj' could not be opened -- PE image doesn't contain managed metadata.
test.cs(2,7): error CS0246: The type or namespace name 'MyAPI' could not be found (are you missing a using directive or an assembly reference?)
After I installed this nuget package in my specflow demo C# .NET Core 3.1 project, I got this error:
Severity Code Description Project File Line Suppression State
Error CS0246 The type or namespace name
'Specflow_Demo_XUnitAssemblyFixture' could not be found (are you
missing a using directive or an assembly
reference?) Specflow.Demo ...\Specflow.Demo\Features\LoggedInDiscount.feature.cs\LoggedInDiscount.feature 3 Active
This is my csproj file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.1.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="SpecFlow.Tools.MsBuild.Generation" Version="3.9.22" />
<PackageReference Include="SpecFlow.xUnit" Version="3.9.22" />
<PackageReference Include="SpecRun.SpecFlow" Version="3.9.7" />
</ItemGroup>
</Project>
After I close all the files in Visual Studio and rebuild, I got another error:
There is an open issue with SpecFlow related to this: Type or namespace [TestNamespace]_XunitAssemblyFixture could not be found. Are you still able to run your test cases? The above link says its an intellisense only issue.
From a comment on the GitHub issue discussion:
The generated assemblyFixture file (e.g.: [TestNamespace]_XunitAssemblyFixture) can be found in the obj folder (obj\Debug\targetframework\xUnit.AssemblyHooks.cs).
We realized that this is IntelliSense related "issue" (IntelliSense of VisualStudio itself, not R#).
As you all noticed, the build was successful, but the error was still there. This is because the generated code behind file (*.feature.cs) is opened in your editor. If you close them, and build again, the error will disappear.
...
BTW there is an ongoing PR which will move the generated files to the obj folder, so this problem will disappear when it'll be merged.
I had a quick look through the types in the referenced nuget packages. None of them uses the naming style that you have there 'Specflow_Demo_XUnitAssemblyFixture' - and none of them has a type with a similar name.
So, as the error says, the type doesnt exist.
I am trying to update a private nuget package and some changes for that has lead to me an error screen of this.
The error essentially is
An error occurred during the compilation of a resource required to process this request. Please review the following specific error details and modify your source code appropriately.
Generated Code
One or more compilation references may be missing. If you're seeing this in a published application, set 'CopyRefAssembliesToPublishDirectory' to true in your project file to ensure files in the refs directory are published.The type or namespace name 'Hosting' does not exist in the namespace 'Microsoft.AspNetCore.Razor' (are you missing an assembly reference?)+[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.Views_Home_Index), #"mvc.1.0.view", #"/Views/Home/Index.cshtml")]
The type or namespace name 'Hosting' does not exist in the namespace 'Microsoft.AspNetCore.Razor' (are you missing an assembly reference?)
I have done my homework by trying various solutions over the net such as
1) setting the CopyRefAssembliesToPublishDirectory' to true in .csproj file.
2) Remove ASP.Net Temporary files
still no luck.
so far i understand that i tried opening a web page and when asp.net tried to compile on the fly as it does it couldn't build the solution.
Is my understanding complete and what else can i do to debug and reach the solution?
Here are some .csproj lines
<TargetFramework>net461</TargetFramework>
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.3" />
<PackageReference Include="System.Net.Http" Version="4.3.3" />
Being the private nature i cant share much of the code but only common things.
any help is much appreciated.
Setting it to <Project Sdk="Microsoft.NET.Sdk.Web" ToolsVersion="15.0"> and including the following files
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.ViewCompilation" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices" Version="2.2.0" /> Helped resolving the issue
I would like to reference the System.Drawing.dll in a console app I am writing using Visual Studio Code on OSX. i.e. I want to use these using statements
using System.Drawing;
using System.Drawing.Imaging;
to avoid this build error
Program.cs(56,20): error CS0246: The type or namespace name `Bitmap' could not be found. Are you missing an assembly reference?
I can't find a tutorial on this, I don't even know if the dll is available in .net core or mono or whatever visual-studio-code uses.
In your .csproj file, add your dependency as a PackageReference in an ItemGroup, then run dotnet restore or nuget restore. Example:
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="Xamarin.iOS" />
<PackageReference Include="Realm" Version="2.1.0" />
<PackageReference Include="xunit">
<Version>2.3.1</Version>
</PackageReference>
</ItemGroup>
Take a look at this article for a full explanation.
The new .NET Core SDK restore command is dotnet restore
To add any asssembly reference in Visual Studio Code, please refer to my post.
Mono offers a WinForms pipeline implementation that you can leverage, that includes support for System.Drawing.