Archive

Author Archive

Using the DIA SDK (Debug Interface Access SDK) from .Net

November 18, 2009 Jendrik Illner Leave a comment

I’m currently working on a new MemorySystem. So I just wanted to access some Debugging Information out of the .pdb file … But this, turned into quite some time spent . The Documentation isn’t really a great help, when you are starting to use the DIA SDK for the first time.

When using the DIA SDK from .Net, even less documentation is available on the Web.

The DIA SDK is a COM component so we can just Add a Reference to it in our C# project.

Under the COM Tab you should find the “dia 2.0 Type Library”, this is the Component you have to add.

clip_image001

If you don’t have the component in the list, as I had. You aren’t lost. The dll is just not registered. We have to do this manually. Normally this should be done by the installer, but the newer versions seem to be not doing this.

Register the dll manually

So start by searching for the DIA SDK directory. This is normally placed under your Visual Studio install directory. When you have multiple version of Visual Studio installed on your computer (as I have) you can choose which version you want to use. I choose to use the Version installed with VS 2010. In most cases you should be using the newest version available to you.

If you have found the directory it’s time to open cmd.exe and move to the \bin folder in the DIA SDK you choose to use.

For me the Path is: D:\Program Files (x86)\Microsoft Visual Studio 10.0\DIA SDK\bin

When you are in the directory, execute the following command, to register the dll.

regsvr32 msdia<VersionNumber>.dll

(For me the file was named: msdia100.dll)

You will now be presented with a window telling you that the dll was registered correctly. If not, you will receive an error.

If you have successfully registered the dll, close Visual Studio and reopen it, so it will reload the references. You should now find the “dia 2.0 Type Library” under the COM components Tab under Add References.

Just add the reference.

Using the DIA SDK to load a .pdb

The following section is not mean to be a complete tutorial, just should show how to use SDK from .Net. From now on always have a look at the Documentation.

The first thing you have to create is a to create a source where the data is coming from.

IDiaDataSource source = new DiaSource();

So now we have to load the actual pdb file. There are multiple possibilities to do this. We can explicitly tell which pdb file to load:

source.loadDataFromPdb(@"D:\Jendrik Illner Projects\C++\TestApplication1\Debug\TestApplication1.pdb");

Or we let the SDK decide which one to use:

source.loadDataForExe(@"D:\Jendrik Illner Projects\C++\TestApplication1\Debug\TestApplication1.exe", @".\Debug", null);

Now we told where the data coming from, but we are not able to access it. For this we have to define and open a IDiaSession.

IDiaSession session;

source.openSession(out session);

Now we are able to access all information available in the PDB file, which can be a huge amount of data.

List all functions from the PDB

This is just a example of what you can do with a PDB file. This will just list all functions listed in the PDB file.

IDiaEnumSymbols results;

session.findChildren(session.globalScope, SymTagEnum.SymTagFunction, null, 0, out results);

foreach (IDiaSymbol symbol in results)
{
      Console.WriteLine(symbol.name);
}

Hope this small Article helps getting you started with the DIA SDK. If you have any questions left unanswered, feel free to ask them.

Categories: all

How to make use of Property Sheets for better solution management for C++ projects in Visual Studio

Setting up a C++ project can take a lot of time and often we are setting the same properties for a lot of projects, so isn’t there a solution to this problem?

Maybe create a custom Project-Template and always create the projects from this template?

Would be feasible but we would need a lot of templates. But what happens if we have to change a property after the project was already created?
We would have to change it for all project by hand …

But there is a a better solution in visual studio for these kind of problems, Property Sheets.

This can help with managing large solutions, but a lot developers don’t know about this feature, because it’s hidden away under the “Other Windows” menu in the shell.

With this post I want to let more people know about this great “hidden” feature of Visual Studio for C++ projects.

What is a Property Sheet?

A Property sheet simply is a .xml file with the file extension .props in Visual Studio 2010 and .vsprops in older versions (2005 and 2008). These file contain property definitions which can than be added to a project so the Properties are automatically set on all projects using the Property Sheet.

But Property Sheets do not contain different configurations, because this would destroy the ease of use.
If you need different settings for different configuration just create multiple Property Sheets.

A Project can use any number of Property Sheets.

What can they be used for?

Property sheets can be used to solve a lot different problems.

I’m using them to place the settings for the different configurations (Debug, Release, Production) outside of the actual projects so I have only one file containing the debug properties, one for release and one for production.

Now every project just has to add these Property Sheets and they are ready to be compiled. With the same settings as every other project in the solution. Using the same Compiler Warning Level, optimization settings, Linker settings and so on.

An other possible use case would be one property sheet for every  external dependency your code is relying on.
For example when we are using boost, we could create a property sheet which contains just the path to header and library directory. So every project which would like to use boost just has to add this property sheet and not have to define the path itself.

Defining a path can take some time, keep in mind if you are compiling for x86 and x64 you have to use different libraries.
So your path has to be defined in a way, it will link to the correct location for the chosen platform which can easily contain an error. If this is the case and you are using a Property Sheet, there is just one place you need to change whether it’s being used in 1 or 20 projects.

These are just some examples, surely there are more problems they can help, just be creative.

How to use?

We talked about the what and why, but now it’s actually time talk about how we actually can use Property Sheets. I will show how to use them in the Visual Studio 2010 Beta 1, but nothing really changed since Visual Studio 2005( in this area) so they versions are mostly equal.

Everything starts with finding the correct window. It’s hidden away under
“View” –> “Other Windows”. There you will find the “Property Manager”.

image

clip_image001[5]

You will now see this unimpressive window. This is the Property Manager.

It contains every project in the Solution with a “Folder” for every Platform/Configuration Combination. Like Debug/x68 and Debug/x64.

There are some buttons, the first one (from left to right) opens the properties for the currently selected item in the list. If the project is selected, the configuration window for the project will be opened.
If a property Sheets is selected, the properties for the selected Sheet will be opened.

When opening the Properties of a Property Sheet you  have to pay attention that just the values which are bold are actually defined in the sheet. The inherited values are also visible but they are not bold.

clip_image001[7]The second button adds a new, empty Property Sheet. The button right from it, adds a already existing Sheet to the project.

With the arrays you can move the priority. The Property sheets inherit values from each other. The Property Sheet which is placed at the top has the highest priority and will override the settings from Property Sheets placed below.

My advise would be to open the Property Sheet in an editor after you have made changes and see if just the value you wanted to set are actually set.

If you have changed any values in a Property Sheet, my advice would be to open the file in an xml editor and have a look at the properties you have changed. So you can be sure that have set the correct values.

Make sure to always save the changes, as they will not be saved automatically.

Some Pitfalls

There are some pitfalls you have to keep an eye on.

The first pitfall is that changes to the Property Sheets are not saved automatically. You manually have to save every Property Sheet you have changed. If you are changing a lot Property Sheets it can happens quickly that you have forgotten to save the changes and you are left wondering, why nothing changed.

My Solution for this problem is: I always close the solution and reopen it after I made any changes. This way Visual Studio will ask, If you want to save you changes and will save all Property Sheets automatically. This takes some seconds but it’s a lot faster than recompiling you project just to find out that you have forgotten to save the changes.

The other one is actually a problem with the UI.
It’s really hard to see how the values for the final project are brought together.
There is no other way to see if a Property Sheet overrides settings from any other Sheet without opening both. It’s also not possible to have two Property Windows open at the same time. Which doesn’t make it any easier, as well.

Conclusion

So i hope I could show the potential of Property Sheets for better Project Management in C++ projects and I also could warn you about the potential problems you may encounter when you are using Property Sheets for the first time.

I think this is a great feature and deservers a better handling in the UI than it currently has. Nothing has changed in the Property windows since Visual Studio 2005 and I think it’s time for a rework of those windows.

Thanks for reading and I hope you learned something new.

Categories: C++, Visual Studio, all

DirectX August 2009 SDK is released

September 10, 2009 Jendrik Illner Leave a comment

Also today is the 10.September 2009, Microsoft released the August SDK today.  The 550MB download is available here

The first thing you will see when you try to open the documentation is that the Documentation is now longer one single file. It’s now placed in two different files and it looks like the Documentation isn’t really completely organized by now. It looks like they wanted to get the SDK out.

You will find the Documentation in the \Documentation\DirectX9 folder,all documentation is placed here. I think the location will change in the next release. This doesn’t look right.

One file is called directx_sdk.chm and contains the documentation for the following technologies

  • DirectX Audio
  • DirectX Input (XInput and DirectInput)
  • Windows Games Explorer
  • Technical Articles
  • Samples and Tutorials

The Samples and Tutorials section also contains the samples for XAudio2, XInput, DirectInput, Direct3D 11, Direct3D 10 and Direct3D 9.

The documentation for the Graphics Technologies are now placed in there own files. In the same \Documentation\DirectX9  folder, you can find the windows_graphics.chm file. This is the documentation for the Graphics Technologies with following content

  • Direct3D 11 Graphics
  • Direct3D 10 Graphics
  • Direct3D 9 Graphics
  • DXGI
  • HLSL
  • Tools for DirectX Graphics

If your are using windows Vista keep an eye on the following site , when it’s available. http://go.microsoft.com/fwlink/?LinkId=160189

This release, is build for the DirectX 11 Runtime. This runtime is installed on Windows 7 RTM versions but has to be installed on Vista machines via a system update. The link will provide more information about it.
I also tested some samples on the Windows 7 Beta and they worked. I don’t have a Vista system to test on but the documentation says some sample may crash on vista without installing the DirectX 11 Runtime.

Interesting new and updated Samples:

The SubD11 Sample once again got updated.  It now contains this nice looking human-model. This samples shows the use of the new Tessellation stage in D3D11, the model also shows skeletal-animation.
Because you have to use the reference device, I really doesn’t make fun to play around with the different settings. Hopefully ATI and NVIDIA will release a D3D11 graphics card quickly.

image

image

VarianceShadows11 Sample demonstrates how to integrate cascaded shadow maps with variance shadow maps.

image

Compute Shader

Also interesting are the new samples for DirectCompute but they have nothing interesting to show on pictures. When you are running Windows 7 with the newest NVIDIA (ATI currently doesn’t have a driver to support it) You can run those samples using DirectCompute using the 4.0 level.

That’s enough for now. Have fun exploring the SDK on your own, I will have it :)

Categories: all

VertexDataAccessor, a helper to access data in a XNA VertexBuffer

August 4, 2009 Jendrik Illner 1 comment

On the XNA-forums somebody asked how-to extract the vertices from a XNA Model. Before answering I firstly searched if there was already a article on the Internet I could link to, but  to my amazement I couldn’t find a real solution which would work for all VertexBuffers.

So I thought that shouldn’t be hard to write a general and more easy way to solve the problem. The old way, which I also have written as answer to the question, involved knowing the vertex declaration and creating a struct based on this. But this isn’t the most elegant way.

A better way is quite simple to implement. I want to describe it in this post and provide my implementation as well.

The Result

Before starting, the Resulting API will look like this:

VertexDataAccessor vertexData = new VertexDataAccessor( mesh.VertexBuffer, mesh.MeshParts[0].VertexDeclaration);

Vector3[] positions = vertexData.GetData<Vector3>(VertexElementUsage.Position);


Introduction; The old way

Before we begin implementing the API shown above, I wanted to show what is necessary to retrieve data from a XNA VertexBuffer, when using the default XNA Model class. If you already know this or aren’t interested in it, feel free to skip this section.

Before we can retrieve any data from the VertexBuffer we firstly have to know what data is available. This is nicely stored in the VertexDeclaration which can be found in the ModelMeshPart contained in a mesh. From this VertexDeclaration we have the possibility to get the VertexElements. This contains information about the usage, the ordering and Types the data in the Buffer.

ModelMeshPart part = mesh.MeshParts[0];
VertexElement[] vertexElements=part.VertexDeclaration.GetVertexElements();

The Content of the VertexElements, we retrieve, could look like this.

[0]: {Stream:0 Offset:0 Format:Vector3 Method:Default Usage:Position UsageIndex:0} 
[1]: {Stream:0 Offset:12 Format:Vector3 Method:Default Usage:Normal UsageIndex:0} 
[2]: {Stream:0 Offset:24 Format:Vector2 Method:Default Usage:TextureCoordinate UsageIndex:0}

We also need the size of each vertex element. This information is also contained in the model Mesh Part.

int sizeInBytes = part.VertexStride;

We can now simply retrieve the data out of the vertex buffer:

VertexPositionNormalTexture[] vertices = new VertexPositionNormalTexture[mesh.VertexBuffer.SizeInBytes / part.VertexStride]; 
mesh.VertexBuffer.GetData<VertexPositionNormalTexture>(vertices);  

We now have the data, but maybe we just wanted the position data, all this work just to get the positions of the vertices? We are also bound to this specific VertexDeclaration. There must be a better way, as you already has seen this way exists and is quite easy to implement.

The better way

VertexDataAccessor vertexData = new VertexDataAccessor( mesh.VertexBuffer, mesh.MeshParts[0].VertexDeclaration);

Vector3[] positions = vertexData.GetData<Vector3>(VertexElementUsage.Position);

This how the result will look, as you have seen above. This is also independent of the actual VertexDeclaration, as long as the requested data is available in the VertexBuffer.

Lets begin implementing it:

Firstly we need a class that will contain the logic, this will be called VertexDataAccessor.
The Construct takes the VertexBuffer and the VertexDeclaration for the VertexBuffer.

public VertexDataAccessor(VertexBuffer vertexBuffer, VertexDeclaration declaration) 
{
    // create the array to hold the vertex buffer
    this.buffers = new VertexBuffer[1];          
    this.buffers[0] = vertexBuffer;              
    this.vertexDeclaration = declaration;         
}

As you can see we simply store the values. The Vertex Buffer will actually be stored in an array because multiple VertexBuffer’s could be used.

Now we have to implement the actual logic to retrieve the data from the Buffer. As you have seen the method for this is called GetData<T> and is a generic method. So it can handle all kinds of requests, but the generics has to be restricted to value types. Because only value types are supported as data inside a VertexBuffer.

public T[] GetData<T>(VertexElementUsage usage) where T:struct

Now to the implementation. The first step is to check if the requested usage is contained in the VertexBuffer. We check this by looking into the VertexDeclaration provided to the constructor.

// firstly check if requested data is available
VertexElement[] vertexElements = this.vertexDeclaration.GetVertexElements();
// this element will contains the requested element, if we can find it
// otherwise we will check the Stream if it is left -1 the vertexElement couldn't be found
VertexElement requestedElement = new VertexElement(-1, 0, VertexElementFormat.Unused, VertexElementMethod.Default, VertexElementUsage.Binormal, 0);

foreach (VertexElement element in vertexElements)
{
    if (element.VertexElementUsage == usage)
    {
        // we found the element describing the request data
        requestedElement = element;
    }
}

if (requestedElement.Stream == -1)
{
    throw new Exception("The requested data with the given VertexElementUsage is not present in the VertexBuffer");
}

The Rest is actually quite easy, as you will see.
We begin by collection the data for the request. The most important one is the offset. The offset define how many bytes at the beginning of each element should be skipped. XNA takes care of copying the right amount of memory into our element data.

We than handle the case that multiple vertex buffers could be used. This information is also in the VertexDeclaration structure, called Stream. So we just have to calculate the number of elements(vertices) in the buffer and create a array that for this number of elements.

Now only copy the data from the VertexBuffer using the VertexBuffer.Get(..) method defined by the XNA framework and were done.

// generate the values we need to get the data out of the vertex buffer
int offset = requestedElement.Offset;
int startIndex = 0; // always copy the complete buffer
int streamID = requestedElement.Stream; 
int vertexStride = this.vertexDeclaration.GetVertexStrideSize(streamID); // the Stream defined which vertex buffer contains the data
int elementCount = this.buffers[streamID].SizeInBytes / vertexStride;
T[] data = new T[elementCount];

// get the actual data out of the vertex buffer
this.buffers[requestedElement.Stream].GetData<T>(offset, data, startIndex, elementCount, vertexStride);
return data;

You can download my implementation, it contains some more methods than shown here, but the actual logical is nearly the same: download

Categories: all

Spore Creatures

The latest spore patch added a “Cheat” to export creatures to Collada. I started playing around with it.

Export a Creature

To export a creature to collada, you have go into the creature editor and bring up the cheat console. (Strg-Shift-C) and type in colladaexport.  The first time you have to accept the EULA. The path for the exported creature is shown in the console.

Importing a static mesh

I started with a creature I had made before. I just exported it and got a 5.3mb colllada file plus a diffuse, normal and specular texture. I now started to import it into the various 3d packages I have access to, but I couldn’t get it into Blender at all. In the Softimage Mod Tool it looked better but just the mesh was imported. It has lost the uv mapping and rigging information, yes the creatures are also rigged, when exported. Which makes it especially interesting.

So now it just tried to export it as .fbx using the 2010.0 FBX Converter. The conversion was successful without any warnings or errors.
So just added it to a xna project and the pipeline imported it. When rendering the model I got this result.

clip_image001

The model is imported correctly, just the texture is missing. SO I had to manually set the diffuse texture and everything looks like it should look.

clip_image001[5]

I tried it with all kind of creatures and everything worked great.

Importing as skinned mesh

As I said before all exported creatures are completely rigged, so I now tried to import and render the meshes as skinned meshes. But as I opened the collada file to see how many bones a creature has, I was a little bit shocked. This mesh had 192 bones.

So I created a new mesh, a lot simpler with just 52 bones. This is ok. My existing skinning solution supported up 80 bones.

I just imported it and everything worked, without any problems.  You can see the skinned model below on the left in the bind pose and on the right with a big toes, just one bone scaled up.

clip_image001[7]

clip_image001[9]

More complex creatures

But now back to my previous test creature,  which has 192 bones. But this creature isn’t the most complex you can build in spore. After some more testing I had to see that creature can get a lot more than 200 bones. The Question, how should I handle those large number of bones? Implement a mesh splitting algorithm or do the skinning on the CPU?
I decided to choose the CPU way, after I couldn’t find any resources about a mesh splitting algorithm on the web.
I just want to play with the creatures for now,  if the performance would be to bad I always could go back and implement skinning on the GPU at a later time.

Current State

I have now implemented skinning on the CPU and I’m able to import and use every creature from the spore universe.

What’s next?

Next step is to implement the creation of animations directly into xna, as I’m not able to get the creatures into any other 3d package I own.

This will be an interesting experiment to get this working.

Categories: all

Using Windows Management Instrumentation(WMI) to get Hardware Information in .Net

I’m currently working on some new projects in .Net which use the new addition for Parallel Programming in the .NET Framework. While developing I noticed that my simple-log really isn’t that great in a Multithreaded Project. I was using a simple text file. I’m now switching to an new log-system, I’m currently working on, but this is a different post.

As I was designing the new log-system I saw that I don’t had any information about the system the application was running on. I was dependent that everybody who send me a log for a bug report also tells me their system information. This wasn’t that clever. So I started to look for a way to get all those data in .Net and I found out that WMI also can be easily be accessed from .Net.

The code to access WMI is in the System.Management namespace. This is in the Assembly with the same name. Which is referenced by default, so don’t forget to add the reference.

When you have found all the different pieces needed to query all the different data you have done the task which takes most of the time. Sadly I haven’t found any resource which had all the links in one place. I will post the links to the documentations you need at the end of the post.

When we have all the documentation open it’s really easy to get a lot of information from the hardware. So lets start.

The first step is to create a ManagementObjectSearcher. A ManagementObjectSearcher returns a collection of ManagementObject based on the query defined when creating the Searcher. The ManagementObjectSearcher overload I will be using here takes two strings. The first argument contains the scope in which the query should be executed and the second argument is the actual query. But lets look at the code:

ManagementObjectSearcher searcher = new ManagementObjectSearcher(“root\\CIMV2″, “SELECT * FROM Win32_Processor”);

This ManagementObjectSearcher queries all the Processors in the “root\\CIMV2” scope, this is the default scope, it contains all the hardware.

Now we have to get the actual processors from the searcher.
foreach (ManagementObject wmiObject in searcher.Get())
{
// [Add Code here]
}
The searcher.Get() methods returns a ManagementObjectCollection so we use a foreach to get the data. Maybe the PC has multiple elements of this kind as well so keep in mind to handle those cases as well.

Now it’s time again to look in the documentation, in this case we have to look at the WIN_32_Processor documentation. At this page you get a look at all the different properties you have access to.

If you have found the name of the property you want to get the data from you just have to call the following code. You just have to replace the string with the name the property you want to get the value from.
object clockSpeedObject = wmiObject.GetPropertyValue(“CurrentClockSpeed”);
uint clockSpeed = (uint) clockSpeedObject;
GetPropertyValue(..) will always return a object so you have to cast it your self, always check the types the Property values is in.

This is everything needed you need to know. Below are some samples showing how to retrieve data from GPU, CPU and RAM.

Hope you find this useful. This article just scratches the surface of what WMI is able to do.

GPU

ManagementObjectSearcher searcher = newManagementObjectSearcher(“root\\CIMV2″, “SELECT * FROM Win32_VideoController”);

foreach (ManagementObject wmiObject in searcher.Get())
{
object memoryInBytes = wmiObject.GetPropertyValue(“AdapterRAM”);

// some video controllers are listed without RAM
// those aren’t real cards, so can we ignore them
if (memoryInBytes != null)
{
// calculate Memory in MB
uint memoryInMB = (uint)memoryInBytes / 1024 / 1024;

string cardName = (string)wmiObject.GetPropertyValue(“Description”);
string driverVersion = (string)wmiObject.GetPropertyValue(“DriverVersion”);
string manufacturer = (string)wmiObject.GetPropertyValue(“AdapterCompatibility”);
}
}

CPU

ManagementObjectSearcher searcher = new ManagementObjectSearcher(
 "root\\CIMV2", "SELECT * FROM Win32_Processor");

foreach (ManagementObject wmiObject in searcher.Get())
{
      object clockSpeedObject = wmiObject.GetPropertyValue("CurrentClockSpeed");

      // get all the informations about the processor
      uint clockSpeed = (uint)wmiObject.GetPropertyValue("CurrentClockSpeed");
      uint physicalCoreCount = (uint)wmiObject.GetPropertyValue("NumberOfCores";
      uint logicalCoreCount = (uint)wmiObject.GetPropertyValue("NumberOfLogicalProcessors");
      string manufacturer = (string)wmiObject.GetPropertyValue("Manufacturer");
      string name = (string)wmiObject.GetPropertyValue("Name");
}

RAM

ManagementObjectSearcher searcher = new ManagementObjectSearcher(
                     "root\\CIMV2", "SELECT * FROM Win32_PhysicalMemory");

int totalMemory = 0;

// calculate the RAM capacity we have
//  we have to add every RAM-Stick Capacity to get the fincal value
foreach (ManagementObject wmiObject in searcher.Get())
{
     ulong capacityInBytes = (ulong)wmiObject.GetPropertyValue("Capacity");
     // calculate in MB
     ulong capacityInMB = capacityInBytes / 1024 / 1024;
     totalMemory += (int)capacityInMB;
}

Links

Categories: all

Opera Unite shareFile problem and solution

WARNING: I’m not very experienced with Opera Unite, the technique presented in this post works for me and doesn’t has to be the best way possible. If you find a better way please let me know.

Opera Unite Version: first release

In Opera Unite all files are on the server and can not be accessed without specify allowing it. But when you share a file using the given APIs opera.webserver.webserver.shareFile(..) method this breaks and becomes unavailable. This seems to be somehow caused be loading the file again while the last download was still running.

As described on http://unitehowto.com/. (Thanks for the great work you are doing)
He found a way to solve this problem, he reloads the scripts on each request but I have thought there has to be an other way.

And I found one while looking through the different examples opera provides with unite. The solution for this problem seems that you have to share and unshare the file on each request. I don’t know if this is a bug or by indent. Opera can you tell us more?

But know I want you to show the solution I came up with.

Everything starts in the window.onload method, this method is called when the service is started. So everything the server has to initialize should be done here.

The first step is to get the webserver and filesystem object. This has nothing to-do specifically with this problem.

var webserver = opera.io.webserver;
var filesystem = opera.io.filesystem;

But the next line is important. You have to mount the the ‘application’ directory.So you have access to the application files.

this.application = filesystem.mountSystemDirectory('application');
webserver.addEventListener('_request', request, false);           

You also have to event Listener for the ‘_request’ event. This event will always be called when a site is requested. In this method we will do the work to make the files available.

And now lets start the most work.

function request(evt) {
    // make alias
    webserver = opera.io.webserver
    var request = evt.connection.request;
    var path = request.uri;

    path = path.substr(webserver.currentServicePath.length, path.length);
    path = path.replace(/\?.*$/, ''); // remove the query path
 
    if (path != "") {
        if (staticFiles[path]) {
            var file = self.application.resolve(staticFiles[path]);
            opera.io.webserver.shareFile(file, path);
            response.closeAndRedispatch();
            opera.io.webserver.unshareFile(file);
            return;
        }
    }

   if (response){
    response.closeAndRedispatch();
   }
}

This is a lot of code so lets get started. We begin the class by getting get webserver, request and the path which was requested.

We now have to remove the current service name from the string. The path has the format

/[serviceName]/[request].

After the service name and query path is removed we have to heck if the path is even contains any data now. If we call the default start site this string will be empty because we haven’t’ requested anything. If the file exists I check in the staticFiles directory if we have a static file defined with the given path. The directory looks like the following,

var staticFiles = { 'imgs/img.jpg': 'sharedFiles/imgs/img.jpg' }

The first element is the path the file should be accessed by the user and the value define the actual path of the file.

If we have defined a static file under the given path we will continue and call application.resolve(..) on the value of the staticFile directory. This gives us the the file we can now share.

for this we call webserver.shareFile(file, path) and feed in the file we just received and the path we generated before.

After the file is shared we call webserver.closeAndRedispatch(). This closes the connection and redispatch the request to the Web server.

After that we just have to unshare the file again. webserver.unshareFile(file) and call return;

But we also have to handle the case if we haven’t defined the static-file the user requested. This is done in the last if(response) block. Here we just webserver.closeAndRedispatch() and let the webserver handle what to do, normally show an 404 Not found error page.

This is everything necessary to get static-files shared without getting the resource broken after some time.

That’s it hope this information is helpful.

Categories: javascript, operaUnite

My Top-3-Developer Tools

The German msdn blog “Softwarehersteller in Deutschland” is asking what are your favorite 3 developer tools and here are mine:

1. Visual Studio + Add-Ins

The first tool I cannot live without is Visual Studio. I always try to use it but sometimes,  in school, I have to use different IDEs .. and then I know again why I love Visual Studio.
Also the Add-Ins available for Visual Studio are so great. I could have listed them as tools as well, but I don’t count them here. Some Add-Ins I’m using a lot are GhostDoc, TortoiseSVN, TestDriven.Net … just to mention some examples.

2. ToDoList – free

The second tool I have chosen is ToDoList. This is a simple but great todo-list management applications.
It has all the features a lot of the expensive tools have, but for free.
The UI isn’t something special but it’s functional and that’s what count.

3. XmlMarker – free

clip_image001XmlMarker is the third tool I have chosen, as I work quite often with xml files.
When the xml-files are small and simple you can manage them in Visual Studio. But when the files get complex and large, as Collada files you can’t deal with them in Visual Studio.
Visual Studio is not designed for those long lines and that much data.

But XmlMarker really handles this great.  This is the best xml-tool I have found and it’s free.

Categories: all

Just some small VS 10 Problems and how-to fix them

Today I just wanted to check some new Add-Ins which added support for Visual Studio 2010 in their latest release.

I wanted to test TestDriven.Net which added support in the 2.22.2468 RTM, Version. Also GhostDoc now supports Visual studio 2010.

Enough commercials for this post :) now it’s time to actually talk about the problems I mentioned and I wanted to write about in the first place.

Problem 1:

The first problem I encountered was that C# intellisense was not showing up for any parameters, it was showing up for everything except parameters. which was really annoying. After some time of searching on google and in the msdn forums I found the solution, here.
This problem was caused by the  Image Insertion Extension, after disabling the extension the problem was solved.

Problem: vs10 intellisense not showing up for parameters
Solution: deactivate/deinstall the Image Insertion extension

Problem 2:

The second problem I had, was that my cursor wasn’t visible in the editor itself. But from time to time it was visible. As i found out this was caused by the RegEx-Editor extension.  After installing a new version this problem was also gone.

Problem: vs10 cursor is not visible
Solution: update RegEx-Editor extension

 

Hope it helps if you had those problems as well.

Categories: all

Some small status updates

First update since a long time, … and I don’t have much to show for now. Currently I’m in the final phase of the school year, this means a lot of exams to learn for and write. Because of that I currently don’t have a lot of time to spend on coding, but only 2 weeks left until all exams are written, than I can spend more time on coding again.

But there are some things I’m working on.

In the past I’ve shown the progress on my D3D11 Engine. Especially on the 3D Content side. After such an long time without working on an actual game, I decided it would finally be time again to work on a new game. 

This game will be a 2D game, simply because when developing a 2D game I can spend more time on the actual code than having to deal with the creation and conversion of 3D files.
I decided to go with an relative easy to program game, a top-down 2D Shooter, because I want to test some different mythologies with this project.
I will try the Agile-Methodology this time, the complete process, not only some parts of it. I will also use Test-Driven-Development as well. 
Also I will try to develop the complete game based on MVC, Model-View-Controller pattern, to see how well it can be used in games.

Lets see how this project will turn out.

This is not everything I’m planning for, as you all know the Dream-Build-Play contest is also taking place this year. I wanted to enter with a new game but currently I don’t have any great idea for a game I would like to enter with…

SlimDX added D3D11 support in their latest release, this is something I want to check out as well.

Visual Studio 2010 also has great support for new type of Add-Ins which directly are integrated into the code view. I have some ideas for Add-Ins I want to see at some point, so I have to try out it as well…

So much I want to do, but so little time…

Categories: all