简体   繁体   中英

Do .Net embedded resources have a size limit?

I'm trying to embed several files into a .Net dll, but one of them isn't showing up in the list of embedded resources, and I don't see any obvious explanation. The only special thing about this file is that it is 77KB in size, and all the other files are < 20KB. Is there a limit to the size of resources that can be embedded?

I googled but didn't find any answer to this (maybe I don't know how to google it).

Any answer will be appreciated.

Thanks!

I think I found a solution, although the problem still isn't clear.

I changed the name of the file.

It was called "Reference.cs.txt", and didn't work

I tried changing it to "_Reference.cs.txt" and it didn't work either.

But when I used "Reference.xcs.txt" it worked...

Maybe someone can share thoughts on why this is happening?

Thanks for your answers though.

I use embedded resources quite a bit. A quick search of my code found at several over 200KB.

Are you sure the Build Action is set to "Embedded Resource"?

Can you give us more details of how you are attempting to access the embedded resource?

You can open the assembly in Reflector to view all of the embedded resources.

I've had the same question, but I am currently using a large CSV myself. I found that using this helps to find the name it is truely using:

Dim allRessources() As String = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceNames()
     For Each rName As String In allRessources
          MsgBox(rName)
     Next

Then, it is important to use the same technique to read the file contents:

Dim oRD As IO.Stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName)
Using reader = New StreamReader(oRD, System.Text.Encoding.ASCII)
    Return reader.ReadToEnd().Replace(vbCrLf, vbLf).Split(vbLf)
End Using

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM