I can't open my Media Asset Catalog in Visual Studio 2017. Why?

TrevorYokumTrevorYokum USMember ✭✭

I've been dealing with a problem for a little over a week now and have finally narrowed it down to images within my application. I'm currently unable to deploy my application in an Ad-Hoc manner.

After some sequence of events, unfortunately I can't remember said sequence, I became unable to open my Media asset catalog in Visual Studio. I previously had done this multiple times to add various, bundled images to use with different screen resolutions. I wrote it off as unimportant because I could deploy to the device in debug mode and see all of my images, whether chosen via UIImage.FromFile("") or UIImage.FromBundle("").

I've recently discovered that either because of this bug, or in relation to this bug, when I build and deploy the application in Ad-Hoc mode (build -> upload IPA -> answer compliance questions -> download for internal testing) I have no pictures and, subsequently, trying to access an image via the FromFile() or FromBundle() methods does not work and crashes the device.

Does anyone have any idea why this is the case? The physical files that were referred to in my Media asset catalog are still alive and well, I just can't see them in the asset catalog editor. It will not even open.

Any idea or guidance is much appreciated. Thanks.

Best Answer

Answers

  • TrevorYokumTrevorYokum USMember ✭✭

    I agree, David. Xamarin.iOS is in a terrible spot right this second and I hope that Microsoft and the folks over at Xamarin start to pay a little bit more attention to the quality of their product.

  • PeterO_dkPeterO_dk DKMember ✭✭

    This is the answer I have posted on StackOverflow for this issue:
    https://stackoverflow.com/questions/40644263/asset-catalog-doesnt-open-in-visual-studio/51747368#51747368

    I have had issues with the Asset Catalogs in Visual Studio, the issue for me was two things that both caused the Asset Catalogs not to open:

    1 Missing/wrong entry in the .csproj file:

    In the Contents.json there was specified a file (i.e. [email protected]) however there was no entry in the .csproj file, this also includes cases where there was an entry in the csproj file but it was the wrong path:

    Solution

    Add the following (or edit the appropriate) line to the csproj file:

    <ImageAsset Include="Resources\Assets.xcassets\image.png.imageset\[email protected]">
      <Visible>false</Visible>
    </ImageAsset>
    

    2 Slashes/Backslashes (seriously?!?)

    In the csproj file for the iOS project, the ImageAsset tag for the image was with the wrong kind of slashes (which is probably why it sometimes works with Xamarin Studio on MacOS / Linux)

    This will look like this when it does not work:

    <ImageAsset Include="Resources/Assets.xcassets/image.png.imageset/[email protected]">
      <Visible>false</Visible>
    </ImageAsset>
    

    Solution

    Reverse the slashes

    <ImageAsset Include="Resources\Assets.xcassets\image.png.imageset\[email protected]">
      <Visible>false</Visible>
    </ImageAsset>
    
Sign In or Register to comment.