Wednesday, November 27, 2013

Use TitleContainer instead of ContentManager for MonoGame for Custom Content Pipeline Processing

So, I've been playing with MonoGame recently and one of the biggest challenges I've had is trying to figure out just how in the world I want to import content.  Especially custom content.

Typically, you load content using the ContentManager.Load<ContentType>(somePathHere) -- but what if I want to manually de/serialize things?  A lot of folks say, "Write a custom content pipeline to handle it."

Problem is -- that's reinventing the wheel.  I already have de/serialization methods.  I know how things are formatted.  The thing that I want now, is to load my content through this without having to do crazy additional content pipeline steps...

After some digging, I found that that you can use the...

Microsoft.Xna.Framework.TitleContainer.OpenStream(somePathHere) method to get you a stream to your content.  There are some caveats -- you will probably still have to build your items into a content project of some sort.  For Windows builds, this is pretty easy, since it's just a matter of dropping files over.  On Android, you apparently have to mark items to be built as an asset.  I haven't looked too deeply into any other platforms than Windows and Android, but I imagine Linux and Mac behave the same as Windows, leaving iOS as the only other weird question.

That being said, I'm going to be abstracting my code into this kind of a pattern (service), so I can manage the content pipeline myself.  I like the idea of being able to manage my own memory without all the extra details.  I'll also be using the Texture2D.FromStream method in conjunction with this, so I can grab my tiles, etc.

Hope that helps some folks!

Tuesday, September 24, 2013

ClickOnce Woes with VSTO's

So, I'm trying to redeploy a VSTO application and I get the following beautiful, beautiful, beautiful error...

Unable to install this application because an application with the same identity is already installed. To install this application, either modify the manifest version for this application or uninstall the preexisting application.

It's frustrating, because I know it has been uninstalled and everything is fine.  Registry doesn't even show it deployed.  Commence "tearing out my hair" mode.

And then, I found the problem.  Apparently, VSTO's can sometimes screw up the ClickOnce cache.  Awesome!  So, that being said, if you run this from the command line (and it's very fast, so don't freak out and think nothing popped up/succeeded) all will be better:

rundll32 dfshim CleanOnlineAppCache

And thus, order and balance was restored to the universe again... for a short time.

Wednesday, September 11, 2013

MSB3326 "Cannot import the following key file: ."

Due to restrictions, I'm limited in some of the things I'm allowed to post, so these updates will be less frequent than before... which isn't saying too much.

In any case, I bumped into a new problem: MSB3326 "Cannot import the following key file: ."

Where is the key file?  Why is it blank?  I know I'd deployed the key and everything was fine prior, so what was the big deal?

What this means is that it cannot access the key file -- maybe you're like me and have to use an alternative administrative account for building and keys and the like.  So, I had to manually open certmgr.msc as the same administrator that was building the project.

After that -- all was pie in the sky.  Things work, life is good, and finally there is an answer to this horrific question.

Tuesday, February 5, 2013

Windows 8 and Windows Server 2012 Hiccups


So, I recently was trying to put together a copy of SharePoint 2013 on Windows Server 2012, on a box that came with Windows 8.  My initial hope was to build a VHD and just have it capable of being transported around easily, but this caused issues.

The more I played with it, the harder it was to get Windows Server 2012 to install at all!  All sorts of trips through bcdedit and bcdboot were fruitless.  So were my attempts at using an easier editor on top.

Even throwing a simple partition on is difficult to install to.  The end result was that I had to go back to the tried and true method -- dump the install to a bootable flash drive.  After doing this, everything went peachy.

For anyone else having issues, this is the only way I was capable of dual-booting Windows 8 and Windows Server 2012, after playing with it in the evenings for a couple of weeks.  

Wednesday, January 16, 2013

SetResourceReference is the Awesome-Sauce for Styling

One of the biggest issues I've had with developing custom views is that there are so many different ways to implement your styling and linkage.  The best way I've found is just to call the following in the constructor:


SetResourceReference(StyleProperty, typeof(MyControl));

Wherein MyControl is the control you're working with.

A lot of people work with the default style key -- but I've found that in larger projects, there can sometimes be issues with this.  Using SetResourceReference has worked for me every single time.

Food for thought!

Monday, January 7, 2013

The type or namespace cannot be found... C# and the Client Profile woes

So, this is a very funny and unusual error I bumped into today -- and it drove me mad for a few hours.

When I build components, I generally like to abstract them out into a little test-bed WPF application.  Every time I kept compiling, it would blow up on a simple, new component I had just added, with a message looking like...

"The type or namespace '{0}' cannot be found."

When I did try to resolve it -- it pointed out a flaw in our architecture, wherein some numb-skull decided to rename a namespace in one assembly to that of another.  After I fixed that, I found that it was STILL not the problem.

Then I looked again -- for whatever I could find -- in my test-bed's properties.

It was set to run in .NET 4.0 Client Profile.  When I changed it back to .NET 4.0, everything compiled and worked fine.

In the future, I need to double check these things -- hopefully someone else will read this post and later figure this out as well!