11 Replies - 1033 Views - Last Post: 10 June 2011 - 01:49 AM Rate Topic: -----

#1 manderson   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 24-March 11

dynamically expanding application

Posted 06 June 2011 - 04:50 AM

Hi,

I am creating an app that reads xml files. These files follow various schemas.

I have used the xsd.exe that comes with VS, however I need to compile the output .cs files.

I have tried using the codedom within my app, however I cannot recompile the new code into to application I am running.

Is it possible to compile into a series of files (one for each file "type") which are automatically included in the main app without a complete recompile.

There are 500 to 600 types ( and always more being added) so generation beforehand is not going to work

Any help would be great

Is This A Good Question/Topic? 0
  • +

Replies To: dynamically expanding application

#2 Curtis Rutland   User is offline

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 5104
  • View blog
  • Posts: 9,283
  • Joined: 08-June 10

Re: dynamically expanding application

Posted 06 June 2011 - 07:12 AM

This certainly won't be an easy task. It is not possible to compile "into" an existing and running assembly. So you can't just dynamically add classes to your existing executable.

However, you can load and use assemblies at runtime. It's not simple, but it's possible:

http://www.codeproje...vokeMethod.aspx
http://msdn.microsof...embly.load.aspx

So if you must use these dynamically generated types, this is how you should do it.

On the other hand, if you're just using these types for validation, there's no real need for it. You can validate XML against an XSD without using xsd.exe.

http://support.microsoft.com/kb/307379
Was This Post Helpful? 2
  • +
  • -

#3 Sergio Tapia   User is offline

  • D.I.C Lover
  • member icon

Reputation: 1258
  • View blog
  • Posts: 4,168
  • Joined: 27-January 10

Re: dynamically expanding application

Posted 06 June 2011 - 07:24 AM

In fact, XML was created with VALIDATION as one of it's cornerstones. :) Use it!
Was This Post Helpful? 0
  • +
  • -

#4 manderson   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 24-March 11

Re: dynamically expanding application

Posted 06 June 2011 - 07:58 AM

Unfortunatly, the xml is being used as an internal data transfer method and for some reason (dont blame me - I didn't write it) it doesn't have a schema attached. So I am having to generate for each file.

I will have a look at the links provided.
Was This Post Helpful? 0
  • +
  • -

#5 Curtis Rutland   User is offline

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 5104
  • View blog
  • Posts: 9,283
  • Joined: 08-June 10

Re: dynamically expanding application

Posted 06 June 2011 - 08:03 AM

Oh, I see. You're generating the schema from the XML itself, not from a schema.

Again, this isn't going to be a simple task. It's basically Reflection...code to deal with code.
Was This Post Helpful? 0
  • +
  • -

#6 manderson   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 24-March 11

Re: dynamically expanding application

Posted 08 June 2011 - 05:42 AM

Ok. Having looked about on google and the links above, I am now lost.

I have had a play with the code, and cannot find out how to load classes and methods from a .cs file
Does anyone know of how I could do this.

Please bare in mind I am doing this in textpad with csc.exe so I am lacking on Intellisense hints.
Was This Post Helpful? 0
  • +
  • -

#7 Curtis Rutland   User is offline

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 5104
  • View blog
  • Posts: 9,283
  • Joined: 08-June 10

Re: dynamically expanding application

Posted 08 June 2011 - 10:14 AM

May I ask why you aree't using VS express? It's free.
Was This Post Helpful? 0
  • +
  • -

#8 manderson   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 24-March 11

Re: dynamically expanding application

Posted 08 June 2011 - 11:13 AM

Its being done on a heavily restricted work based pc, no method of installing it, no rights etcs.

I have requested vs2008, which we hold a site licence for, but to no avail.
Was This Post Helpful? 0
  • +
  • -

#9 Sergio Tapia   User is offline

  • D.I.C Lover
  • member icon

Reputation: 1258
  • View blog
  • Posts: 4,168
  • Joined: 27-January 10

Re: dynamically expanding application

Posted 08 June 2011 - 11:18 AM

Personally I would talk to HR and let them know you can't do your job because IT (or whoever is responsible) is being overzealous about their security.
Was This Post Helpful? 0
  • +
  • -

#10 Curtis Rutland   User is offline

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 5104
  • View blog
  • Posts: 9,283
  • Joined: 08-June 10

Re: dynamically expanding application

Posted 08 June 2011 - 11:19 AM

Wow. I couldn't work for a company that wouldn't give me the tools I need to do my job. It's like asking a carpenter to build a house without a hammer.

But back on topic, I can't explain anything more clearly than the links I've provided can. As I've said several times, this isn't a simple thing. This is a very very complicated topic.
Was This Post Helpful? 0
  • +
  • -

#11 manderson   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 24-March 11

Re: dynamically expanding application

Posted 08 June 2011 - 11:56 AM

Technically dev isn't my job. I'm a tester. But in downtime I put together (usually simple) tools that help the rest of the team do analysis. I don't even have Internet access to research from, I am on my phone!

I have managed to put together a simple class that reads a cs file, compiles it to memory. The class technically stores an assembly which I can then use Invoke methods on.

Next step: working out how to use the xsd.exe generated dataset.
Was This Post Helpful? 0
  • +
  • -

#12 manderson   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 24-March 11

Re: dynamically expanding application

Posted 10 June 2011 - 01:49 AM

Hi,

Managed to get something running, and populated. But, still majorly unsure how to get a dataset returned from the object returned.


Any ideas?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1