Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7057333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:58:24+00:00 2026-05-28T03:58:24+00:00

How do i mark as assembly as safe? Alternatively, how do i have Visual

  • 0

How do i mark as assembly as “safe”?

Alternatively, how do i have Visual Studio tell me when something in my assembly is not “safe”?


Sometimes you cannot use an assembly unless it is “safe” (e.g. from SQL Server).

i would like my assembly to be marked as safe. If my assembly cannot be marked as safe because it’s not safe, i’d like to know how i can know that my assembly is not safe.


There are some concepts in Visual Studio that seem to relate to safe-ness, that may or may not have anything to do with an assembly being “safe”:

  1. Allow unsafe code assembly option:

    enter image description here

    • What is allowed if i check the allow unsafe code option?
    • What is not allowed if i uncheck the allow unsafe code option?
    • What relation, if any, does “unsafe code” have to do with an assembly being “safe”?

      (i ask because my assembly doesn’t “allow unsafe code”, but allows P/Invoke calls – which i thought was the definition of “unsafe”)

  2. ClsCompliant assembly option:

    [assembly: CLSCompliant(true)]
    namespace MyApplication
    
    • What is the relation, if any, does “cls compliant” code have to do with an assembly being “safe”?
  3. unsafe code block:

    int error;
    unsafe
    {
        error = 0x80004005;
    }    
    

    The code inside the unsafe block is “unsafe”

  4. UnsafeNativeMathods

    Microsoft recommends creating a class called UnsafeNativeMethods that contain unsafe managed code:

    [SuppressUnmanagedCodeSecurity]
    internal static class UnsafeNativeMethods
    {
       ...          
    }
    

    This contrasts with SafeNativeMethods:

    [SuppressUnmanagedCodeSecurity]
    internal static class SafeNativeMethods
    {
       ...          
    }
    

    that contains safe native methods, and NativeMethods:

    internal static class SafeNativeMethods
    {
       ...          
    }
    

    that contain native methods.

How do i mark as assembly as “safe”?

How does SQL know that as assembly is “not safe”?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:58:25+00:00Added an answer on May 28, 2026 at 3:58 am
    • Reading from this, the “Safe” for SQL Server is a:

    SAFE is the most restrictive permission set.
    Code executed by an assembly with SAFE permissions cannot access
    external system resources such as files, the network, environment
    variables, or the registry

    so its about code execution permission set inside SQL Server code domain

    • Unsafe flag from VS has nothing to do, basically, with code execution security, but enables non managed code execution. So this about non managed code integration into managed code base

    • CLS Compilant attribute as defined here is about defining the code of the assembly marked with that attribute like a code that follows CSL (Common Language Specification) guideline. So this about compilation and code architecture.

    How do i mark as assembly as “safe”?

    It defined in the first link in this answer and has relation with SQL Server integration.

    How does SQL know that as assembly is “not safe”?

    Considering description provided: “Creates a managed application module that contains class metadata and managed code as an object in an instance of SQL Server”, SQL Server relays on metadata, that in some fields provides an information about the fact if it is “safe” or not.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have a project and I mark it as <Assembly: CLSCompliant(True)> Do I
I have a C# assembly that I use as an in-proc COM server consumed
I am trying to use the Visual Studio editor to create XML files in
Possible Duplicate: Is it possible to mark an assembly as deprecated? I have the
I have a mixed-mode DLL built in visual studio 2005. In dependency walker, my
I'd like to mark some specific properties in a foreign assembly that i'm referencing
Mark Edington mentioned a Memory Manager called, SafeMM at the DelphiLive conference. I have
I have always marked my .NET assemblies as visible to COM with [assembly: ComVisible(true)]
I have an issue that has me stumped. We have a model assembly and
I have an application that compiles some code dynamically, and creates an assembly as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.