简体   繁体   中英

How to get project GUID in runtime of .netcore?

I'm the newer of .netcore.

Now, I have a sql connection string using guid to encrypt, and I generate a guid in project.

<PropertyGroup>
    ...
    <ProjectGuid>{D830E0EE-9D0B-4FC2-A609-4661990159D2}</ProjectGuid>
</PropertyGroup>

Then, I want to get it when runtime for decrypt, and I try to do below:

object[] guids = assembly.GetCustomAttributes(typeof(GuidAttribute), false);
string guid = ((GuidAttribute)guids[0]).Value;

The GetCustomAttributes could not use in here, because it is not assembly .

How can I do anything?

Thx.

This information is not compiled into your application and not available at runtime.

If you bundle a secret with your application, it will not be secret because no extra privileges are needed to load the secret into memory.

If you use SqlServer use Integrated Security. In that case, you don't deal with passwords at all and the user account is used. Such mechanism is available to many database systems, even if you don't use SqlServer.

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