Проблемы с файлом resx
Проект не хочет компилироваться.
Ошибка:
не удалось обработать файл «Form.resx», так как он находится в Интернете или ограниченной зоне либо имеет веб-метку. Чтобы обрабатывать такие файлы, следует удалить веб-метку
Добавлено через 55 секунд
При попытке открыть файл «Form.resx» пишет невозможно загрузить из-за отсутствия доверия
94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
Ответы с готовыми решениями:
Проблемы с .exe файлом
При запуске .exe файла выводит сообщение: "Версия этого файла несовместима с использованием.
Проблемы с файлом css
Добрый день, в шаблоне требуется немного изменить стиль: изменить цвет меню и убрать картинку перед.
Проблемы с командным файлом
Здравствуйте! Есть следующее задание: 1. Вывести на экран текущую дату. 2. Установить текущим.
Проблемы с XML файлом.
mr_dronski вы писали программку для Нади. Мне тоже нужно было такуюже написать, но там структура.
Invalid Resx file. Could not load type error why?
Error 1 Invalid Resx file. Could not load type System.Collections.Generic.List`1[[TestProjectForProperty.Test.TypeDescriptorBase, TestProjectForProperty, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 which is used in the .RESX file. Ensure that the necessary references have been added to your project. Line 134, position 5. . \visual studio 2010\Projects\TestProjectForProperty\TestProjectForProperty\Form1.resx 134 5 TestProjectForProperty
In the Resx file there is data field with base64 encoded stuff inside when this error is present. I have been searching for an answer, but the best i got is to restart everything, it didn’t help me, do you guys have any suggestions? I’m using .net 4 client and visual studio 2010
3,197 3 3 gold badges 28 28 silver badges 49 49 bronze badges
asked Dec 12, 2013 at 18:11
Attila Horváth Attila Horváth
562 1 1 gold badge 5 5 silver badges 16 16 bronze badges
6 Answers 6
In my experience, this is due to a change of version of a referenced library, or a change of the lib itself, which contains the backing type of a property you have defined in your user control. The solution is to «force» the visual studio designer to re-initialize it’s designer code for that type, and not expect to retrieve a «canned» version of it from the .resx file of the control.
1) Delete the offending data section in the .resx file of your control. This will be a section in the xml of the .resx file associated with your user control, which has a node: — the name attribute will be set to whatever you’ve named that object in the properties of whatever you added this type to. The /data> section contains a base64 encoded string that is the encoded form of the name and version of the library the type comes from. This is where the problem ism, because it now contains an encoded version of the library and/or version number you are no longer referencing in order to include the type. Delete the entire /data> section, from opening to closing tag, save the change and close the file. Now the «artifact» is gone.
2) Now find the place in the designer file for your control, where the type is instantiated; this is initialization code generated for you by visual studio, and it is the place that is expecting to load a «canned» definition of the type from the base64 encoded string contained within the .resx file. The line will look something like this:
this.myCtrlFoo.MyPropertyFroo = ((MyNamespaceFoo.MyTypeFoo)(resources.GetObject("myCtrlFoo.MyPropertyFroo")));
. now just replace the resources.GetObjec call with the instantiation of a new instance of the appropriate type like so:
this.myCtrlFoo.MyPropertyFroo = ((MyNamespaceFoo.MyTypeFoo)(new MyNamespaceFoo.MyTypeFoo()));
. now save the change to the file, close it, rebuild, and everything should now build & run OK.
Couldn’t process file resx due to its being in the Internet or Restricted zone or having the mark of the web on the file
If you downloaded the file from the internet, either separately or inside a .zip file or similar, it may have been «locked» because it is flagged as coming from the internet zone. Many programs will use this as a sign that the content should not be trusted.
The simplest solution is to right-click the file in Windows Explorer, select Properties, and along the bottom of this dialog, you should have an «Unblock» option. Remember to click OK to accept the change.
If you got the file from an archive, it is usually better to unblock the archive first, if the file is flagged as coming from the internet zone, and you unzip it, that flag might propagate to many of the files you just unarchived. If you unblock first, the unarchived files should be fine.
There’s also a Powershell command for this, Unblock-File:
> Unblock-File *
Additionally, there are ways to write code that will remove the lock as well.
From the comments by @Defcon1: You can also combine Unblock-File with Get-ChildItem to create a pipeline that unblocks file recursively. Since Unblock-File has no way to find files recursively by itself, you have to use Get-ChildItem to do that part.
> Get-ChildItem -Path '' -Recurse | Unblock-File