I have created a Asp.Net 5 project with some rest APIs. I have added a reference to another class library. I can see that the reference has been added in the DNX 4.5.2 (MessageQueue)references however it has not been added to the DNX Core 5.0 references.
When I try to pull in the Namespace I'm allowed to use the class but the project wont build as it says that the namespace has not been declared. This is really starting to get frustrating. Any help would be appreciated.
Thanks
Chris
DNX Core 5.0 is a lightweight version of the framework optimized for cloud. If you do not need to support it just remove from "frameworks" in project.json.
// comment out or delete.
"dnxcore50": { }
Related
To recap how .net framework references work: Assume I have a .net framework class project called ProjectFw which references a .dll called Grpc.dll. When I create a new Solution as a .net framework console project called ProjectFwRef which adds a reference to ProjectFw.dll the build automatically brings the .dll Grpc.dll into the release folder of ProjectFwRef.
But .net 5.0 does not do that: Assume I have a .net 5.0 class project called ProjectNet which references a package called Grpc. When I create a new Solution as a .net 5.0 console project called ProjectNetRef which adds a reference to ProjectNet.dll the build DOES NOT automatically bring the Grpc.dll nor Grpc package into the release folder of ProjectNetRef.
This fundamental difference in how foreign .dlls are imported into a .net 5.0 project begs the question of the best way to deal with it. One obvious answer is to manually add the package Grpc to ProjectNetRef. Am I missing a better solution? What if I do not know the .dll's a foreign project references? Do I have to wait for the dreaded 'Cannot load file or assembly' error to find out what package I should have added?
I am playing with .NET Standard and found strange that if I have the following project.json specified for both a .NET Core class library (xproj) and a Portable Class Library (csharp), only the latter can be properly referenced from a Xamarin.Android project:
{
"supports": {},
"dependencies": {
"NETStandard.Library": "1.6.0",
"Microsoft.NETCore.Portable.Compatibility": "1.0.1"
},
"frameworks": {
"netstandard1.4": {}
}
}
I can add both as a reference, dotnet update works as expected (or at least no error messages shown), but the .NET core library is not realized:
type or namespace could not be found
I find this strange, since I'd expect any .NET standard targeting library to work properly. Am I doing something wrong or intentionally only PCLs are supported from Xamarin?
I assume you have a .csproj for the Xamarin.Android project and an .xproj for your .NET Core class library, which is targeting .NET Standard.
I believe the issue might be because of the different project systems we currently have and where each of them expects to find built assemblies for project references.
A workaround is to manually edit the .csproj to include the reference with the correct hint path. For example:
<Reference Include="SomeOtherClassLibrary">
<HintPath>..\SomeOtherClassLibrary\bin\$(Configuration)\netstandard1.6\SomeOtherClassLibrary.dll</HintPath>
</Reference>
You may also need to manually add a build dependency from the Xamarin.Android to the class library project to ensure the projects are built in the correct order (right click the Xamarin.Android project in Solution Explorer Build Dependencies > Project Dependencies...).
In summary, it's not that .NET Standard targeted libraries don't work with Xamarin, or that Xamarin only supports PCLs. It's a quirk with project references and the current state of the tooling, which I am sure will improve in time.
I have a website that was written with .net 4.5.2. and MVC 5.
I want to keep it at that framework version, as the 3rd party libraries it uses have not yet been updated to use .net 5.
However, I like the new project structure. Is it possible to convert the existing project over to the new project structure, or to create a project from scratch and add the older .net framework to it?
I found a way to do this:
Create a new empty project with the new structure.
Edit the "frameworks" section of project.json:
"frameworks": {
"net452": { }
}
Use Nuget to add MVC and the other libraries. (Not the Add reference Dialog as with the old project style.)
Is there any way to find which SDK used to create the xcode project. Actually I have source code for the project but not aware which SDK used to create that project. The problem right now I am facing is using the latest SDK the xcode shows some reference error with an external library which is linked by the project. And these libraries are compiled at the time of the project created.
And I am thinking like, if I use the same SDK which is used to create the project at first time, the linking problem will not happen, and I can start working with the project. Please correct me if I am wrong.
Thanks and regards,
Haris
I've been playing around with the Starter Edition of Xamarin Studio to determine if it will meet my needs. I understand (so I thought) the limitations of this edition; 32K compiled IL limit, no native libraries, etc. Now, I understand native libraries to be C/C++ libraries, or even native Java libraries. This does not seem to be the case.
I have a solution in Xamarin Studio with 2 projects. One is an Android Class Library, the other is an Android Application. When I reference the class library from the application project and build, I get the following error.
Your app references native libraries. This functionality requires Indie Edition or higher.
I beg to differ! Every .cs file in the referenced Android class library project is simple .NET code. What am I missing? I can successfully run the Tasky Android_Starter solution without issue, and it is made up of 2 projects like mine.
I had to delete the Resources folder and manually edit the Android class library project file in order to get this working. I looked at the Tasky sample's project file as a reference.
After deleting the auto-included Resources folder from the project, edit the .csproj file in a text editor to remove the following XML elements:
Project\ProjectGroup\AndroidResgenFile
Project\ProjectGroup\AndroidResgenClass
With those things taken care of, I no longer get the error. I'm guessing, Xamarin Studio thought I was referencing another Android application instead of a class library. Not sure why the default project template includes things to break such a flow, but perhaps I'm not "doing" right" either. Go figure.
Deleting the Resources folder and manually editing the csproj file didn't work for me. I had to create a new C# Library project instead of creating an Android Library Project and import my .cs files into that. After that it compiled and ran fine.