Pointers (unsafe) in Customization

Is there a way to tell the compiler to compile in an unsafe mode from a customization (like one would do in VS)?

Elaborate a bit please. What are you trying to accomplish?

1 Like

As far as I know, you cant execute unsafe C# code in customization

Yeah, It was a long shot…in case if somebody had a magic trick.

Someone on StackOverflow explained it pretty good:

No, this is (currently) not possible, as the entire assembly is affected by having unsafe code in it.

By including unsafe code in your assembly, you are telling the CLR that the assembly could do something, well, unsafe, which changes how the runtime acts when it loads the assembly. The biggest change here is that the CLR will simply not try to verify your unsafe code, but it also will refuse to load your assembly unless it has full-trust (e.g. you couldn’t load an unsafe assembly as a normal user over click-once.)

From a technical perspective, when you use the /unsafe option, it causes the compiler to emit the IL equivalent of the following module-level attributes into your assembly:

[assembly:SecurityPermission(SkipVerification = true)]

Your best option is, to isolate the unsafe code into its own separate assembly as much as possible. The fact that the assembly has only one class in it is much less of a code-smell than tainting an entire assembly full of safe code due to one unsafe class.

I don’t know of any config where Epicor allows you specify it’s compilation flags - or a .csproj file to define


Perhaps what you are trying to accomplish can be accomplished without unsafe code? I know in MES I couldn’t even use SendKeys while in Full Client I could. Maybe there is a better way, if we knew what your end goal was :slight_smile:

1 Like