views:

503

answers:

3

When I try to inspect DataSet by standard DataSet visualizer I see this error "could not load this custom viewer". I wrote simple dataset visualizer, but error throws anyway too.

On other computers with the same configuration visualizer show without any errors.

OS: Windows 7 x86 (Release)

VS: Visual Studio 2010 RC

has somebody any ideas?

I reinstall VS with no effect.

A: 

The best way to diagnose this is to debug Visual Studio itself. Try the following

  • Get Visual Studio into the state where you want to use your Visualizer
  • Attach another version of Visual Studio to the original one (managed only)
  • Disable Just My Code (Tools -> Options -> Debugger -> uncheck "Just my Code")
  • Go to Debug -> Exceptions
  • Check the Throw box for "CLR Exceptions"
  • Switch back to the first VS and Attempt to show your Visualizer

This should throw an exception which will then show up in the second instance of Visual Studio. Please post back with this information if it's not enough to solve your problem.

JaredPar
Ok! It's a good idea. I did that and see the next exception:"The security state of an AppDomain was modified by an AppDomainManager configured with the NoSecurityChanges flag."BTW, just this exception i saw when try compile project with added to references COM-object dll.Solving that problems I not found too.
LionSoft
+1  A: 

I found the cause of this error. According this advice http://go.microsoft.com/fwlink/?LinkID=155570 I add to devenv.exe.config this parameter NetFx40_LegacySecurityPolicy enabled="true" and with this parameter in .config file I have the error when try to open DataSet visualizer.

When I remove this parameter all became ok. Execption "The security state of an AppDomain was modified by an AppDomainManager configured with the NoSecurityChanges flag" fixed too.

But I NEED NetFx40_LegacySecurityPolicy enabled="true" parameter to work with old projects.

LionSoft
@LionSoft I have same problem with Devexpress controls and Silverlight in same project. Any workarounds?
Sergey Mirvoda
Same problem here. DevExpress controls not working. Looks like we're going to have to wait for DevExpress to update their stuff.
wizlb
I solve the problem. See my answer.
LionSoft
A: 

I found workaround! I changed source code of DevExpress module and recompile it. After that I undo parameter to NetFx40_LegacySecurityPolicy enabled="false", and enjoy. :)

File is "%DeveloperExpress.NET%\Sources\DevExpress.Data\Utils\Security.cs"

using System;
using System.Security;
using System.Security.Permissions;
namespace DevExpress.Data.Helpers {
    public static class SecurityHelper {
        public static bool IsPartialTrust {
            get {
                return !IsPermissionGranted(new ReflectionPermission(ReflectionPermissionFlag.MemberAccess));
            }
        }
        public static bool IsPermissionGranted(IPermission permission) {
            bool result = true;
/* (changed by Lion)
            try {
                PermissionSet ps = SecurityManager.ResolvePolicy((System.Security.Policy.Evidence)null);
                ps = ps.Copy();
                ps.AddPermission(permission);
                ps.Demand();
            }
            catch (SecurityException) {
                result = false;
            }
*/
            return result;
        }
    }
}

Patched file for version 8.2 you can download from here

LionSoft