Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

Visual Studio 2012 Update 2 Portable Class Library issues


View products that this article applies to.

Introduction

Portable Class Libraries issues may occur after you install Microsoft Visual Studio 2012 Update 2 . This article describes those issues and their workarounds.

↑ Back to the top


Issue 1

Symptoms

When you use resources to build a Portable Class Library project after you install Visual Studio 2012 Update 2 , you may receive the following error messages:

'System.Type' does not contain a definition for 'Assembly' and no extension method 'Assembly' accepting a first argument of type 'System.Type' could be found (are you missing a using directive or an assembly reference?)

Note You receive this error when you use Microsoft Visual C#.

'Assembly' is not a member of 'System.Type'

Note You receive this error when you use Microsoft Visual Basic.

This issue occurs when one of the following platforms is targeted in your project:
  • The Microsoft .NET Framework 4.5 and the .NET for Windows Store apps
  • The .NET Framework 4.5 and Windows Phone 8
  • The .NET Framework 4.5, the .NET for Windows Store apps, and Windows Phone 8

Workaround

To work around this issue, fix the designer-generated code of the resources file. To do this, double-click the error message, and then follow these steps:

For Visual C#

  1. Add the following using directive:
    using System.Reflection;
  2. Find the following code:
    typeof(Resource1).Assembly
    Replace that code with the following code:
    typeof(Resource1).GetTypeInfo().Assembly
The following code is an example that has this issue:
        /// <summary> 

/// Returns the cached ResourceManager instance used by this class.

/// </summary>

[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]internal static global::System.Resources.ResourceManager ResourceManager { get {

if (object.ReferenceEquals(resourceMan, null)) {

global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PortableClassLibrary2.Resource1", typeof(Resource1).Assembly);

resourceMan = temp;

}

return resourceMan;
}
}

Visual Basic

  1. Add the following using directive:
    Imports System.Reflection;
  2. Find the following code:
    GetType(Resource1).Assembly
    Replace that code with the following code:
    GetType(Resource1).GetTypeInfo().Assembly
The following code is an example that has this issue:
        '''<summary>

''' Returns the cached ResourceManager instance used by this class.

'''</summary>

<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _

Friend Shared ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager

Get

If Object.ReferenceEquals(resourceMan, Nothing) Then

Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("PortableClassLibrary1.Resource1", GetType(Resource1).Assembly)

resourceMan = temp

End If

Return resourceMan

End Get

End Property

↑ Back to the top


Issue 2

Symptoms

You cannot use resources to build a Portable Class Library project after you install Visual Studio 2012 Update 2 . Additionally, you may receive one of many different error messages. For example, you may receive one of the following error messages:

The type 'System.Net.HttpStatusCode' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Net, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'.

Cannot implicitly convert type 'System.Net.HttpStatusCode' to 'System.Net.HttpStatusCode [%programfiles%\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.5\Profile\Profile78\System.Net.Primitives.dll]'

Note
 This issue occurs when one of the following platforms is targeted in your project:
  • The .NET Framework 4.5 and Windows Phone 8
  • The .NET Framework 4.5, the .NET for Windows Store apps, and Windows Phone 8

Cause

This issue occurs because Visual Studio 2012 Update 2 was installed after the Windows Phone Software Development Kit (SDK) 8.0 was installed. Therefore, the following files were deleted:
  • %programfiles%\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.5\Profile\Profile49\System.Net.dll
  • %programfiles%\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.5\Profile\Profile49\System.ServiceModel.dll
  • %programfiles%\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.5\Profile\Profile78\System.Net.dll
  • %programfiles%\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.5\Profile\Profile78\System.ServiceModel.dll

Workaround

To resolve this issue, run the Visual Studio 2012 repair program. To do this, follow these steps:
  1. Click Start, click Control Panel, click Programs, and then click Programs and Features.
  2. Right-click the version of Visual Studio 2012 that you have installed, and then click Change.
  3. Click Repair when the Visual Studio 2012 Setup wizard opens.
Note If you set up a new developer environment, to avoid this issue, you should install Visual Studio 2012 Update 2 before you install the Windows Phone 8.0 SDK.

↑ Back to the top


Status

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

↑ Back to the top


Keywords: kbsurveynew, kbtshoot, kbexpertiseadvanced, kb

↑ Back to the top

Article Info
Article ID : 2840147
Revision : 1
Created on : 1/7/2017
Published on : 5/2/2013
Exists online : False
Views : 309