Using EVEMon Data with LINQPad

Saturday, July 31st, 2010

LINQPad is an awesome aide to .NET Developers. Written by Joseph Albahari of LinqBridge and the C# In a Nutshell series fame. LINQPad allows the developer to write, compile and run C# or VB.NET Expressions, Statements of Programs outside of Visual Studio.

Everything I am going to show you in this post can be done with Visual Studio simply by wrapping the text in a new console application, and adding references to the DLLs. However I strongly encourage you to download LINQPad and give it a go.

In the event you are using 64-bit windows and are still using LINQPad 2 you will need to download the x86 version of LINQPad 2, as all of the EVEMon assemblies are compiled for x86. If you have LINQPad 4 you don’t need to worry about.

Assuming you have EVEMon installed, the first step is to load the EVEMon.Common.dll assembly into LINQPad:

  1. Go ahead and fire up LINQPad ensure you have a new query window open
  2. Press F4 (Query -> Query Properties).
  3. Click the “Browse…” button at the bottom of the properties window.
  4. Navigate to the EVEMon install directory.
  5. Select “EVEMon.Common.dll”

While you have “Query Properties” open go to the “Additional Namespace Import” tab and add the following two lines:

EVEMon.Common.Data
EVEMon.Common

EVEMon.Common was designed to work as part of a long running process, namely the EVEMon application sitting in your system tray from when you turn your computer on until you turn it off, as such we need load the static data from the data files.

EveClient.Initialize();

Now we get to do some LINQ,

var allItems = from item in StaticItems.AllItems
	       where item.Family == ItemFamily.Ship
	       select new
	       {
	           item.Name,
	           item.Race,
	           CPU = item.Properties[DBConstants.CPUOutputPropertyID].Value.Value,
	           PG = item.Properties[DBConstants.PGOutputPropertyID].Value.Value,
	           item.Description
	       };

I could start to explain the above line by line, but there are lots of really good LINQ articles on the Internet, including one by Joseph Albahari. We will just say that the above pulls all of the ships out of EVEMon’s Items data file and selects the Name, Race, CPU, PowerGrid and Description property for each one.

Now we see my favorite aspect of LINQPad, the .Dump() extension method, simply running the following command:

allItems.Dump();

Will output the data we have just queried as a nice HTML Table:

That is all I have for you for now, I am working on a project that uses this data outside of EVEMon, keep an eye on Twitter where I will hopefully be providing a link for testing in the not too far distant future.

Fixing EVEMon’s Crashy C++ DLLs

Saturday, April 18th, 2009

I have been working on EVEMon for about two months now, taking on the responsibility of committing changes to the trunk, fixing bugs and adding new features. As a project I have been involved for several years submitting bug fixes and little features, it was down to my experiences with EVEMon that I decided to implement Subversion and Trac at work.

Unfortunately the first time it came to me to be responsible for a release, it seemed to go terribly wrong. The updated installer worked fine, and it seemed initially there were no problems with the updated code base. However BattleClinic shortly went a little mad with bug reports similar to this one:

EVEMon Version: 1.2.7.1283
.NET Runtime Version: 2.0.50727.1434
Operating System: Microsoft Windows NT 6.0.6001 Service Pack 1
Executable Path: “C:\Program Files\EVEMon\EVEMon.exe”

System.IO.FileLoadException: Could not load file or assembly ‘lgLCDNETWrapper, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null’ or one of its dependencies. The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log for more detail. (Exception from HRESULT: 0x800736B1)
File name: ‘lgLCDNETWrapper, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null’ —> System.Runtime.InteropServices.COMException (0x800736B1): The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log for more detail. (Exception from HRESULT: 0x800736B1)
at EVEMon.LogitechG15.Lcdisplay.Dispose(Boolean bDisposing)
at EVEMon.LogitechG15.Lcdisplay.Finalize() in D:\EVEMon\EveMon.LogitechG15\Lcdisplay.cs:line 70

For those who are not familiar the above is the crash report generated by EVEMon when a .NET exception is unhandled. lgLCDNETWrapper is the C++ library EVEMon uses to communicate with the Logitech G15. A similar error was generated for EVEMons other C++ component the window relocator.

Tonto Auri quickly spotted that the problem was something to do with the re-compiled C++ DLLs and switching the new DLLs with those from an older package resolved the problems. Whilst this was a fix, I wasn’t willing to just revert the changes and give up on the changes we had made to the G15 library, additionally I was concerned that we had not made changes to the window relocation code and that was causing at least one person a problem.

Quite a bit of searching about with Google and Stack Overflow resulting in finding these two little gems of information:

These two posts basically gave me the tools and the knowledge to fix EVEMon’s problems.

First I made the sudden (and “facepalm”) realization that EVEMon deployed the Visual Studio 2005 Redistributable; we had moved to Visual Studio 2008 SP1 about a month before the release of 1.2.7. I confirmed this with the Dependency Walker utility, by walking lgLCDNETWrapper.dll I was able to confirm that version 9.0.21022.8 of the Microsoft CRT Library (Microsoft.VC90.CRT) would be required.

The next trick was figuring out which re-distributables to deploy with EVEMon to ensure the end user would have all the dependencies required to use all of the features; frustratingly it seems that Microsoft only bundles the latest version of the re-distributables with Visual Studio 2008 and that was version 9.0.30729.1 which was not going to cut it.

Enter Nuonsofts excellent article providing a step by step guide on adding the required compiler flags to ensure the latest version of the CRT was bound. I did find a nice GUI resource editor that was capable of getting the manifests out in XN Resource Editor which made the process a little faster.

A little bit of hacking later the updated Visual Studio 2008 SP1 CRT DLLs and manifest file were deployed to the Microsoft.VC90.CRT folder within the EVEMon program files directory as the VC80 CRT libraries were in the past and the two C++ projects were setup to bind to the latest version with the _BIND_TO_CURRENT_CRT_VERSION=1 preprocessor definition.

A bit more poking arround with XN Resource Editor and Dependency Walker showed we were now in a far better position to have a working copy of EVEMon in the hands of our end users.

Driving Lesson #20

Monday, November 10th, 2008

So today was a mock test, one of several before I take my actual test. We drove down to the test center in Brighton Marina where Kev explained the test to me, how majors and minors worked and what would score as what. I still haven’t done emergency stops so we could not cover that, other than that it seemed pretty much as I had read and expected.

Kev got me to do three manoeuvres, the first was turning round in the road, which I did, not without hitting the kerb (I forgot to steer when reversing) so that was a major. Reverse parking was difficult as it was pitch black and my steering was off at best so Kev had to intervene as I was misjudging the position of the car rather seriously. Reverse round the corner went better, however I hit the kerb again as I overcompensated – all three would be easier in the daylight so I am not overly concerned about them.

My general driving wasn’t that bad, in a couple of places I was slow to move off, and my use of mirrors and the MSPSL routine left something to be desired, particularly after making a mistake.

In the end I had 4 majors and 13 minors, which isn’t too bad – it does show how important plenty of practice is.

So, next week should be more practice. In the mean time I have bought myself a copy of Focus’s Driving Test Successs – Practical Simulator which seems okay, not really that close to actual driving although I think it is helping me learn the sequences.

Going to give myself tonight off to watch Spooks and maybe play a little Team Fortress 2 or EVE Online (Who have their winter expansion released tomorrow).

Back to the Urban Battlefield

Monday, September 15th, 2008

No, I haven’t taken up free running I have just been playing a little more Call of Duty 4 over the past week, I was encouraged to look back at it by a friend some time ago. Only just got round to trying it again.

Since I last played there has been another patch, that includes new maps (I thought there were four maps, however I have only played three.

I seem to be playing fairly well still, I go through phases where I can get some awesome scores for a map or two a few matches later I can’t seem to get a single kill in. Finished the above match a few minutes ago – decided it was best to call it a night and end on a high rather than risk a crushing defeat in the next match.

The community seems to have matured, there are more clans hosting public servers that they actually play on and there are fewer M302 spammers around it seems. A wider range of weapons in use for the different roles, and occasionally organized teams of randoms all going stealth (my preferred class – Silenced MP5, Silenced USP .45, 3 Frag Grenades, UAV Jammer, Dead Silence and a stun grenade). This is probably the class that gets me the most kills.

My main tactic is slowly move around the map with one or two other people dressed for stealth, taking people out as we go. Aim for head shots where possible you can usually predict where people are going to pop up, in the corner of windows in between gaps in walls. The range of the silenced MP5 is severely reduced so sniping from a distance can only be done with short bursts (i usually try to squeeze out two or three bullets with two short clicks).

The more I play it the more I wonder if I might enjoy being in a clan that is on a competitive gaming ladder. Then again what with playing EVE, Team Fortress 2 and AudioSurf fairly regularly makes me wonder if I would ever have the time.

Nate Combs on “Security” as an resource

Monday, September 17th, 2007

Nate Combs has again posted on Terra Nova about what makes rare minerals rare. Nate makes the very good point; that rare minerals are not as scarce as the name might suggest. It is well worth a read as his his personal “scratchpad”.

Blocking Adverts

Thursday, September 13th, 2007

I read an interesting article on The Register about the Firefox Plugin AdBlock Plus, the article covers a bit about the current favourable relationship between Firefox and Google which could be threatened by the increased usage of products that block adverts from being displayed.

I am no fan of adverts on websites, as you can see; this site is devoid of adverts for the conscious reason that I find them distracting. Many adverts can not be controlled, if I add adverts to a page then I am leaving some of my screen space open to be used by another company, doubtlessly this company will have different views on what is appropriate, perhaps they promote content I would find objectionable (betting or breaking of game rules for example).

This of course doesn’t mean that you can’t make any money out of blogs and other user generated content, my personal preferences is contextual links, not the automatically generated JavaScript kind but the ones that the author puts in his or herself. For example affiliate links to Amazon or Barnes and Noble for books and music, Eclipse Internet to recommend as an ISP or EVE Online to encourage people to join you in-game. So many companies run successful affiliate programs why do so many people still invest so much time and clunky and unappealing design constraints just so that they can include an advert?

I would be really interested in the thoughts of readers, does anyone else use AdBlock? do adverts on sites annoy you? or do you see them as a fact of life, after all they do pay for the free content we are consuming?

Economics of Virtual Worlds

Tuesday, September 11th, 2007

I have been thinking about the economics of Online Games (specificly MMORPGs) for some time. Most of my interest comes from writing my undergraduate dissertation which was more of an overview of the future of MMOGs than any specific focus. Lately, and most importantly with EVE Online, economics has shot into the public eye.

First CCP Employed an Economist, Dr. Eyjólfur Guðmundsson, which as it turns out is probably the first time an Economist has been employed to study and create reports based upon an ingame economy. Dr Guðmundsson has already posted a blog item about the Mineral Market in EVE Online although he describes it himself as more of a “statistical overview” than an in-depth study.

I am certainly not alone in my interest in Virtual World Economics as there is at least one “research network” who actively post about research found on the internet and in acedemia. A good number of posts over the past few years over at Terra Nova have considered the implications of applying real world economic principals to Virtual Worlds, Edward Castronova wrote a book about them, of which I have a copy which I still haven’t read.

The thing that facinates me most is probably they way you can maniuplate a virtual world’s market and not get sent to prison for it. You can collude with other players to fix prices buy up entire stocks of a particular item only to put it back on the market again at an artificially inflated rate! I am sure that people reading this who play EVE would say that that is unfair or even worthy of outwrite wrath. However who is to say that it is a bad thing? it all leads on to the Good vs. Evil argument and the question “is it wrong to do something in a virtual world just because it is wrong in the real world?”

So what does the future hold for virtual economys, well I can see lots of research comming from big university’s… I mean why wouldn’t they, if an economy such as EVE Online’s can act so much like that of the real world why not use it as a economic study. I also expect real world corporations to start accepting virtual economy “experence” as a creadable experence for job applicants. This has already started happening with MDs and CEOs of small technology companies getting the job because of past leadership experence within World of Warcraft.

Well now that is cool!

Tuesday, October 3rd, 2006

A friend of mine from EVE, Planetside and OcPS has managed to get some of his photo graphs on his local BBC website, you can see the gallery here and more photographs on his website here