locked
Pulling in .NETFramework v4.0 DLLs in a PCL Project RRS feed

  • Question

  • I'm trying to pull together a WinRT version of an app that currently runs on Windows 7. I've tried to conform to the Windows Store App guidelines, but this is never actually going to be uploaded to the Windows Store. If folks like the proof-of-concept, we'll consider doing a full-up WintRT version from there.

    Still, I need to get this demo running quickly, and so I created a Portable Class Library (PCL) project in my WinRT demo app, and referenced one of the Windows 7 DLLs. That worked, until the Windows 7 DLL got to a method that needs the following reference:

    C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Web.dll

    I tried adding a Reference to System.Web to the PCL project, but I still get the "System.Web not found" runtime error. I also added the folder above to the System Path environment variable and restarted Visual Studio 2012, but still get the same error.

    I can just copy the DLLs from the directory above into my bin\Debug folder. Still, I'm wondering if there's a better way, like maybe a manifest entry. If a better way exists, I'd love a pointer.

    Thanks...


    Randy

    Thursday, November 7, 2013 1:25 PM

Answers

  • Your steps will list all components in the Object Browser, not just ones available in the .NET Portable Subset. It will select the first node from the item you referenced.

    You can limit the Object Browser to just your solution or to just the .NET Portable Subset in the "Browse" combo at the top of the pane.

    --Rob

    Thursday, November 7, 2013 5:52 PM
    Moderator

All replies

  • You cannot use System.Web in a Windows Store app. See .NET for Windows Store apps overview for more information about which parts of .Net are valid.

    Whether the app needs to pass certification or not doesn't affect this. 

    --Rob

    Thursday, November 7, 2013 3:03 PM
    Moderator
  • Thanks, as always, for the answer.

    When I created my Portable Class Library (PCL) project, it automatically gave me a reference to ".NET Portable Subset". When I look at ".NET Portable Subset" in the object browser, it contains the System.Web 4.0 and System.Web.Services 4.0, including the SoapHttpClientProtocol used in the Windows 7 DLL I was hoping to reference.

    How does a programmer reference anything inside the '.NET Portable Subset"?

    I ask because one possible approach is to pull in the source code from the DLL I was hoping to just reference, and recode anything that's not totally compatible. Of course, if I can find a way to use the SoapHttpClientProtocol inside my Portable Class Library, that would save a lot of recoding.

    Again, I'm just doing a proof-of-concept, so doing it "right" isn't as important as getting something working quickly.

    Thanks...


    Randy


    Thursday, November 7, 2013 4:39 PM
  • System.Web and SoapHttpClientProtocol shouldn't be available in the .NET Portable Subset and I don't see them in the Object Browser in a test project. Maybe you have it targeting something wider?

    There aren't any quick hacks to allow using .Net Framework classes outside of the .Net for Windows Store apps section in a Windows Store app. The framework itself will prevent that.

    You'll need to port that code to use the Windows.Web or the available System.Net classes. See Connecting to web services .

    --Rob

    Thursday, November 7, 2013 5:16 PM
    Moderator
  • Thanks for all the good pointers.

    In my PCL project: References -> .NET Portable Subset -> View in Object Browser -> System.Web.Services [4.0.0.0] -> System.Web.Services.Protocols -> SoapHttpClientProtocol

    I think I'll go back to importing/rewriting the source code, rather than just trying to Reference the Windows 7 DLL. Still, if there's a link that describes accessing the SoapHttpClientProtocol above, I'd love to take a look.

    And sorry, I should have mentioned that SoapHttpClientProtocol is in System.Web.Services, not System.Web.

    Thanks again!


    Randy


    Thursday, November 7, 2013 5:36 PM
  • Your steps will list all components in the Object Browser, not just ones available in the .NET Portable Subset. It will select the first node from the item you referenced.

    You can limit the Object Browser to just your solution or to just the .NET Portable Subset in the "Browse" combo at the top of the pane.

    --Rob

    Thursday, November 7, 2013 5:52 PM
    Moderator