views:

42

answers:

1

I've seen some examples, but trying to better understand how "Resource" files work, such as embedding images, reports, schemas, etc.

If building an application, I want to make sure everything is available when deployed, but for things like reports and schemas, I don't want anyone accidentally deleting, renaming, or otherwise mucking around with the content of things. So, embedding these types of items appears to make sense. Then, I just access via the dll via the resources manager.

Since I have not done this yet... Am I correct in the assumption that my final deployed stuff will be a bunch of dlls, and I can check to make sure all required exist before continuing the app. Then, all the reports and schemas I can get out of the "resource" dll assembly.

Additionally, since I already have some samples of about 5 reports, and their corresponding schemas that are NOT in a "resource" file, what is involved with adding these existing elements into a "resource" file and being able to run them. I know they all appear to have some embedded pathing things themselves, such as the report knowing where it's schema is coming from. If the actual files are not part of the deployment, just extracted from the "resource", will it choke?

Hope this is all making sense as this area of utilizing resource files is relatively new to me.

Thanks

A: 

For visual studio, it's pretty much drag and drop:

  1. Create resource file
  2. Open resource file
  3. Switch to files view
  4. Drag files from Solution Explorer into design surface
  5. Save

At that point, an accessor class will have been created. The accessor class will have the same name as the base name of the resource file. Depending on the type of content of the files, it will have either a byte-array or string property for each embedded file.

There are other ways to do it but none are as simple as that.

Although that appeared to work, I'm having a problem with the report with respect to the schema. Can you embed the schema as well into the resource? I did, but don't know how to change the reference in the report to NOT look into what WAS a subfolder of "schemas" in my project.
DRapp
You can embed any file. There is a slight possibility that, if you are embedding it as a text file, your content is being munged. In that case, you would need to switch to binary. Otherwise, there is no reason you shouldn't be able to embed your schema file.