Announcement

Collapse
No announcement yet.

The type 'Object' is defined in an assembly that is not referenced ...

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    The type 'Object' is defined in an assembly that is not referenced ...

    Hi,
    I am a newbie at .NET development - I'm switching from Java after couple of years. We're starting a project that will need multiple third party libraries, and Bridge seems as a great representation of converter that we need. Although I run into a problem and can't find solution even after long hours of searching. Considering my lack of experience in given technology, I'd be very pleased if you could help me out:

    I created a sample project in Visual Studio and added third party dependency injection framework to it via NuGet, called Simple Injector. Then I added Bridge, also using NuGet. After that, it's not possible for me to use even basic functionality of Simple Injector without getting this error:

    CS0012 The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=4.0.0.0, ...
    I found out that Bridge actually removes System namespace references and uses its own implementation of many classes.
    I assume that given third party library references original System namespace and therefore problem occurs after removing references.

    I guess there has to be this problem with many third party libraries, but I couldn't find any solution that would work for me. Is there any way to set references up correctly?

    I'm also including my .csproj file:

    <?xml version="1.0" encoding="utf-8"?>
    <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
      <PropertyGroup>
        <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
        <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
        <ProjectGuid>{A1AB3E1A-89B1-4F26-9D4B-310BB6F52AF9}</ProjectGuid>
        <OutputType>Library</OutputType>
        <AppDesignerFolder>Properties</AppDesignerFolder>
        <RootNamespace>ClassLibrary8</RootNamespace>
        <AssemblyName>ClassLibrary8</AssemblyName>
        <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
        <FileAlignment>512</FileAlignment>
        <Deterministic>true</Deterministic>
        <NuGetPackageImportStamp>
        </NuGetPackageImportStamp>
      </PropertyGroup>
      <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
        <DebugSymbols>true</DebugSymbols>
        <DebugType>full</DebugType>
        <Optimize>false</Optimize>
        <OutputPath>bin\Debug\</OutputPath>
        <DefineConstants>DEBUG;TRACE</DefineConstants>
        <ErrorReport>prompt</ErrorReport>
        <WarningLevel>4</WarningLevel>
        <NoStdLib>true</NoStdLib>
      </PropertyGroup>
      <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
        <DebugType>pdbonly</DebugType>
        <Optimize>true</Optimize>
        <OutputPath>bin\Release\</OutputPath>
        <DefineConstants>TRACE</DefineConstants>
        <ErrorReport>prompt</ErrorReport>
        <WarningLevel>4</WarningLevel>
        <NoStdLib>true</NoStdLib>
      </PropertyGroup>
      <ItemGroup>
        <Reference Include="Bridge, Version=17.7.0.0, Culture=neutral, processorArchitecture=MSIL">
          <HintPath>..\packages\Bridge.Core.17.7.0\lib\net40\Bridge.dll</HintPath>
        </Reference>
        <Reference Include="SimpleInjector, Version=4.5.1.0, Culture=neutral, PublicKeyToken=984cb50dea722e99, processorArchitecture=MSIL">
          <HintPath>..\packages\SimpleInjector.4.5.1\lib\net45\SimpleInjector.dll</HintPath>
        </Reference>
      </ItemGroup>
      <ItemGroup>
        <Compile Include="Class1.cs" />
        <Compile Include="Properties\AssemblyInfo.cs" />
      </ItemGroup>
      <ItemGroup>
        <None Include="bridge.json" />
        <None Include="packages.config" />
      </ItemGroup>
      <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
      <Import Project="..\packages\Bridge.Min.17.7.0\build\Bridge.Min.targets" Condition="Exists('..\packages\Bridge.Min.17.7.0\build\Bridge.Min.targets')" />
      <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
        <PropertyGroup>
          <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
        </PropertyGroup>
        <Error Condition="!Exists('..\packages\Bridge.Min.17.7.0\build\Bridge.Min.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Bridge.Min.17.7.0\build\Bridge.Min.targets'))" />
      </Target>
    </Project>
    Thanks a lot,
    Patrik

    #2
    Hi Patrik,

    Welcome to Bridge! Thanks for the excellent question.

    At this time, Bridge cannot reference non-Bridge Assemblies. All Assemblies in the project must be Bridge enabled projects, so directly referencing the SimpleInjector project is not going to work. SimpleInjector would need to be compiled with Bridge first, then that Assembly referenced in your project.

    Hope this helps clarify things.

    Comment


      #3
      Thanks for explanation.

      So let's say that I will do the following:
      1. add SimpleInjector sources as separate project to my solution
      2. add Bridge to it like I did to my project
      3. referenced this SimpleInjector project with Bridge in my project, instead of assembly downloaded via NuGet
      would it theoretically work?

      If yes, there are two more questions that come to my mind:
      1. What about build (conversion) process? Would it work out-of-box this way or there would be some advanced configuration needed?
      2. I guess that SimpleInjector (or any other thrid party framework) contains lot of code, so there's a big chance that some of it will not be supported for conversion by Bridge. Am I right? Is there any list of supported/unsupported parts of .NET framework?
      If my DIY solution wouldn't work, do you know about any asseblies that are, like you said, "Bridge enabled" ? It would be nice to have list of such ones.

      Comment


        #4
        would it theoretically work?
        Yes, theoretically it would work, but I suspect it will not in this case because SimpleInjector itself likely references other 3rd party Assemblies that themselves would also need to be Bridge enabled projects.

        There's another problem. With the current release, Bridge does not support compiling of .NET Core projects, only .NET Framework.

        It's a tough situation and we wish we had the resources (time + money) to build .NET Core support into Bridge, but currently, it's not possible.

        Comment


          #5
          Thank you for your effort.

          By the way, I ran into this project recently: https://retyped.com/
          Do you know it? It seems that it offers many 3rd party libraries and is Bridge enabled. I'll have a look if I can find alternative dependency injection framework there.
          If not, at least it can be useful for someone reading this.

          Comment


            #6
            Hello Patrik!

            Retyped is a project from this same company, see at the bottom of the page "A project of Object.NET". Our Deck code fiddler has extensive support for it (not that all libraries are included in Deck).

            hope this helps!

            Comment

            Working...
            X