none
type exists in BOTH assemblies (BUT FOR GOOD REASONS) RRS feed

  • Question

  • Hi Folks

    I've been kind of forced between a "rock and a hard place" in terms of what we refer to as our "Global Directory" (SSO - single sign-on services) and how SQL Server 2012 SSRS works as well.

    1. What I need to do with SSRS 2012 is a "hardwired" at .Net v3.5 (its a Microsoft.ReportServices.Interfaces.dll kind of thing).

    2. What we've hardwired into our own development for SSO is .Net v4.5.1 (and no, unfortunately our software environment is NOT VERSIONED/wasn't history'd and checkpointed for use at various versions (for adaptability in area like this), etc..

    3. I've managed to construct a CONSOLE application which does the up-n-down "thunking" between the .Net versions with a main program and 2 dlls. So we basically go back and forth WITHOUT ISSUE (SSRS v3.5-up/down thunk-v4.5.1 SSO). If you REALLY want the previous gory details, you can look here: https://social.msdn.microsoft.com/Forums/vstudio/en-US/d27d3c40-66cd-45a8-b036-b3d1211ace2f/typegettypefromprogid-not-returning-systemmarshalbyrefobject?forum=netfxbcl&prof=required (there's diagrams, discussions, etc.)

    The way this up-and-down thunking was done, was via  Interfaces (and was the only way I know of to do anything like this). The "trickery" was binding Interfaces from different DLLs with the same name.

    This works great in a simple CONSOLE application, but in the context of SSRS and COM registered assemblies it can come around and bite you quickly ;)

    Back to my problem... When I execute this code:

                try
                {
                    Type myClassAdapterType = Type.GetTypeFromProgID("Net35ToNet4xAdapter.MyClassAdapter");
                    Object myClassAdapterInstance = Activator.CreateInstance(myClassAdapterType);
                    Net35ToNet4xAdapter.IMyClassAdapter myClassAdapter = (Net35ToNet4xAdapter.IMyClassAdapter)myClassAdapterInstance;

    on the last line, I get the error:

    The type 'Net35ToNet4xAdapter.IMyClassAdapter' exists in both 'DMx.CustomDataProcessingExtension.dll' and 'Net35ToNet4xAdapter.dll'...

    Which is correct, IMyClassAdapter DOES exist in both.  This is the only way to go back and forth in .NET.

    Is there a simple way to cast/cast as the myClassAdapterInstance as a particular dll with that mentioned interface?

    Thanks

    Rob





    Rob K

    Friday, October 31, 2014 6:24 PM

Answers

  • If I get it right, you have referenced 2 dlls both having an interface with the same namespace and name.

    Then you should add different aliases to referenced libraries (in reference properties window), and specify alias-prefixed type name. For example, if you add alias "bridge" for Net35ToNet4xAdapter.dll, it would be something like:

    // in the beginning of the namespace
    extern alias bridge;
    
    // ...
    bridge::Net35ToNet4xAdapter.IMyClassAdapter myClassAdapter =    
        (bridge::Net35ToNet4xAdapter.IMyClassAdapter)myClassAdapterInstance;


    Saturday, November 1, 2014 11:09 AM
  • step# 16 here:

    http://blogs.msdn.com/b/ansonh/archive/2006/09/28/extern-alias-walkthrough.aspx

    is where I seem to be choking with this error:

    Error    54    The extern alias 'adapter' was not specified in a /reference option    C:\SSRSDPE\CustomDataExtension\DataSet\DsConnection.cs    1    1    CustomDataProcessingExtension

    What amazes me about the extern declaration is that intelli-stupids in VS2103 recognizes all of the adapter references and changes this:

    adapter::Net35ToNet4xAdapter.IMyClassAdapter myClassAdapter = (adapter::Net35ToNet4xAdapter.IMyClassAdapter)myClassAdapterInstance;

    to

    IMyClassAdapter myClassAdapter = (IMyClassAdapter) myClassAdapterInstance;

    so I know I'm in the "ball park".

    also, there are a variety of VS2013 bugs related to creating aliases, but it didn't look like the cases that I read about (WPF, XAML, etc.) were applicable to my DLLs.

    Looking in the CustomDataProcessingExtension.csproj, I see this:

    :

    :

      <ItemGroup>
        <Reference Include="Microsoft.ReportingServices.Interfaces">
          <HintPath>C:\dmsax\DMSAX for AX 2012 R2\Rel\v1.0\HF\Bin\3rdParty\Microsoft.ReportingServices.Interfaces.dll</HintPath>
        </Reference>
        <Reference Include="Net35ToNet4xAdapter, Version=1.0.0.0, Culture=neutral, PublicKeyToken=09abb560dc6eacfe, processorArchitecture=x86">
          <SpecificVersion>False</SpecificVersion>
          <HintPath>Net35ToNet4xAdapter\obj\Debug\Net35ToNet4xAdapter.dll</HintPath>
          <Aliases>adapter</Aliases>
        </Reference>

    :

    :


    Rob K




    • Edited by ebiz-tutor Monday, November 3, 2014 4:31 PM more info
    • Marked as answer by Fred BaoModerator Monday, November 10, 2014 8:55 AM
    Monday, November 3, 2014 3:21 PM

All replies

  • When a same class exists in two different namespaces (libraries) you have to specify the full pathname including name space. So instead of using Client use System.Net.Client.  In your case it would be the names space and class that is duplicated.

    jdweng

    Friday, October 31, 2014 7:55 PM
  • If I get it right, you have referenced 2 dlls both having an interface with the same namespace and name.

    Then you should add different aliases to referenced libraries (in reference properties window), and specify alias-prefixed type name. For example, if you add alias "bridge" for Net35ToNet4xAdapter.dll, it would be something like:

    // in the beginning of the namespace
    extern alias bridge;
    
    // ...
    bridge::Net35ToNet4xAdapter.IMyClassAdapter myClassAdapter =    
        (bridge::Net35ToNet4xAdapter.IMyClassAdapter)myClassAdapterInstance;


    Saturday, November 1, 2014 11:09 AM
  • I will check this on Monday. This is what I was looking for (I'm pretty sure)

    Thanks

    Rob


    Rob K

    Saturday, November 1, 2014 12:07 PM
  • Hi

    What is a "reference properties window"?

    From the project properties I see Application..thru..Code Analysis. Is this the area you are referring to?

    Here's some more background information:

    Interfaces

    Console application (prototype)

    SSRS Custom Data Processing Extension

    .Net Version

     

     

     

     

    IMyClassAdapter

    Net35Assembly.cs

    CustomDataProcessingExtension.dll

    3.5

    IMyClassAdapter

    Net35ToNet4xAdapter.dll

    Net35ToNet4xAdapter.dll

    4.5.1

     

    Net4xAssembly.dll

    Net4xAssembly.dlll

    4.5.1

     

     

     

     

     

    I really wanted to stay totally away from COM (and stick with an app.manifest approach), but had to throw in the towel on my preferred approach

     

    HOW THINGS ARE REGISTERED IN COM (not COM+)

     

    CustomDataProcessingExtension.dll has no COM registration requirement, it is simply a helper to the SSRS Microsoft.ReportingServices.Interfaces.dll functionality

    Nothing required, it is only deployed

     

     

    c:\Windows\Microsoft.Net\Framework\v4.0.30319\RegSvcs /appname:Net35ToNet4xAdapter

    “C:\Program Files\Microsoft SQL Server\MSRS11.MSSQLSERVER\Reporting Services\ReportServer\bin\Net35ToNet4xAdapter.dll”

    Register

    c:\Windows\Microsoft.Net\Framework\v4.0.30319\RegSvcs /u /appname:Net35ToNet4xAdapter

    “C:\Program Files\Microsoft SQL Server\MSRS11.MSSQLSERVER\Reporting Services\ReportServer\bin\Net35ToNet4xAdapter.dll”

    UnRegister

    c:\Windows\Microsoft.Net\Framework\v4.0.30319\RegSvcs /appname:Net35ToNet4xAdapter

    “C:\Program Files\Microsoft SQL Server\MSRS11.MSSQLSERVER\Reporting Services\ReportServer\bin\Net35ToNet4xAdapter.dll”

    RE-Register (simply ignore the prompted warning)

     

     

    c:\Windows\Microsoft.Net\Framework\v4.0.30319\RegSvcs /appname:Net4xAssembly

    “C:\Program Files\Microsoft SQL Server\MSRS11.MSSQLSERVER\Reporting Services\ReportServer\bin\Net4xAssembly.dll”

    Register

    c:\Windows\Microsoft.Net\Framework\v4.0.30319\RegSvcs /u /appname:Net4xAssembly

    “C:\Program Files\Microsoft SQL Server\MSRS11.MSSQLSERVER\Reporting Services\ReportServer\bin\Net4xAssembly.dll”

    UnRegister

    c:\Windows\Microsoft.Net\Framework\v4.0.30319\RegSvcs /appname:Net4xAssembly

    “C:\Program Files\Microsoft SQL Server\MSRS11.MSSQLSERVER\Reporting Services\ReportServer\bin\Net4xAssembly.dll”

    RE-Register (simply ignore the prompted warning)

     


    Rob K

    Monday, November 3, 2014 2:27 PM
  • 1. I added a reference to Net35ToNet4xAdapter.dll in CustomDataProcessingExtension.dll (which wasn't there before)

    2. I went to the reference properties, for the item "Aliases" and changed it from global to "adapter" (for

    Net35ToNet4xAdapter.dll in CustomDataProcessingExtension.dll)

    3. I changed this

    Net35ToNet4xAdapter.IMyClassAdapter myClassAdapter =    
        (Net35ToNet4xAdapter.IMyClassAdapter)myClassAdapterInstance;

    to

    adapter::Net35ToNet4xAdapter.IMyClassAdapter myClassAdapter =    
        (adapter::Net35ToNet4xAdapter.IMyClassAdapter)myClassAdapterInstance;

    4. I now get the error: Error    54    Alias 'adapter' not found    C:\SSRSDPE\CustomDataExtension\DataSet\DsConnection.cs    46    5    CustomDataProcessingExtension


    Rob K

    Monday, November 3, 2014 3:07 PM
  • step# 16 here:

    http://blogs.msdn.com/b/ansonh/archive/2006/09/28/extern-alias-walkthrough.aspx

    is where I seem to be choking with this error:

    Error    54    The extern alias 'adapter' was not specified in a /reference option    C:\SSRSDPE\CustomDataExtension\DataSet\DsConnection.cs    1    1    CustomDataProcessingExtension

    What amazes me about the extern declaration is that intelli-stupids in VS2103 recognizes all of the adapter references and changes this:

    adapter::Net35ToNet4xAdapter.IMyClassAdapter myClassAdapter = (adapter::Net35ToNet4xAdapter.IMyClassAdapter)myClassAdapterInstance;

    to

    IMyClassAdapter myClassAdapter = (IMyClassAdapter) myClassAdapterInstance;

    so I know I'm in the "ball park".

    also, there are a variety of VS2013 bugs related to creating aliases, but it didn't look like the cases that I read about (WPF, XAML, etc.) were applicable to my DLLs.

    Looking in the CustomDataProcessingExtension.csproj, I see this:

    :

    :

      <ItemGroup>
        <Reference Include="Microsoft.ReportingServices.Interfaces">
          <HintPath>C:\dmsax\DMSAX for AX 2012 R2\Rel\v1.0\HF\Bin\3rdParty\Microsoft.ReportingServices.Interfaces.dll</HintPath>
        </Reference>
        <Reference Include="Net35ToNet4xAdapter, Version=1.0.0.0, Culture=neutral, PublicKeyToken=09abb560dc6eacfe, processorArchitecture=x86">
          <SpecificVersion>False</SpecificVersion>
          <HintPath>Net35ToNet4xAdapter\obj\Debug\Net35ToNet4xAdapter.dll</HintPath>
          <Aliases>adapter</Aliases>
        </Reference>

    :

    :


    Rob K




    • Edited by ebiz-tutor Monday, November 3, 2014 4:31 PM more info
    • Marked as answer by Fred BaoModerator Monday, November 10, 2014 8:55 AM
    Monday, November 3, 2014 3:21 PM
  • Why are you creating alias?   If you internet is working then you should be able to connect prvided the following

    1) You IP is recognized over the internet.

    2) The port you are using isn't blocked.


    jdweng

    Monday, November 3, 2014 5:08 PM
  • i get the same errors others are seeing (but for them its WPF or XAML). I had not thought that this would be applicable here, but same thing as here:

    http://www.windows-tech.info/4/06b9c89527a9157e.php

    thanks


    Rob K

    Monday, November 3, 2014 5:54 PM
  • hi

    this is a compile issue (and really nothing to do with the internet).

    issue here is that the same interface and type is defined in 2 dlls.

    (but there's a valid reason here, i.e. this interface is used to "thunk" between different versions of .NET (v3.5-to-v4.5.1)

    Rob


    Rob K

    Monday, November 3, 2014 9:14 PM
  • Hello Rob,

    It seems that you have solved this issue, I would mark Alex reply and one of yours as an answer for this issue, if you do not this that is helpful, please unmark it.

    Thanks for your understanding.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, November 10, 2014 8:55 AM
    Moderator
  • (sorry it took me so long to get back to the group)

    This IS NOT doable in .Net v3.5 compilation.

    MS Support Ticket# 114110712007762

    We did find a way around this however (and if interested, please let me know and I'll offer a way to get around this).

    Rob


    Rob K

    Sunday, December 21, 2014 12:32 PM