sharepoint enterprise – InvalidOperationException: Could not get algorithm from X509AsymmetricSecurityKey to make Client Context for SP 2016 in VS 2019

I’m trying to create a context to SP 2016 site with the help of a certificate using following piece of code:

OfficeDevPnP.Core.AuthenticationManager othManager = new OfficeDevPnP.Core.AuthenticationManager();
System.Security.Cryptography.X509Certificates.X509Certificate2 cert = new System.Security.Cryptography.X509Certificates.X509Certificate2({certificate path}, {password to access Certificate});
ClientContext oContext = othManager.GetHighTrustCertificateAppOnlyAuthenticatedContext({siteurl}, {clientID}, cert, {certificate issuer id});
Web objWeb = oContext.Web;
oContext.Load(objWeb);
oContext.ExecuteQuery();
string webTitle = objWeb.Title;

However, it is running fine on Visual Studio 2015 but I have various solutions in VS 2019 so it is throwing following exception in VS 2019:

InvalidOperationException: Could not get algorithm from X509AsymmetricSecurityKey

Even tried following in App.config file of my application but issue persists:

<system.web>
<compilation debug="true" targetFramework="4.7.2"/>
<httpRuntime targetFramework="4.6.1"/>
</system.web>

Any help would be much appreciated!

entity framework – C# Winforms App ,EF6, DB First with Auto Mapper Generic Repository and UOW context is not updated automatically when database is changed externally

I’ve started to work on a single user c# winforms application, with EF6 db first approach, AutoMapper, Generic Repository and UnitOfWork. They have been previously implemented by others former colleagues . I’m not very experienced with those concepts but I have read a lot of links.
The main issue is now that the single user c# app needs to be updated for multiuser environment. Using the current implementation , the external changes(like update operations) performed on database are not visible inside de controller.

I’ve tried using _unitOfWork.Context.Refresh(System.Data.Entity.Core.Objects.RefreshMode.StoreWins, _tableRepository.FindAllInContext()); to refresh the context but I think this is not a good option, because if I try to update a table column value after refresh, the action will not be saved in database.

 public interface IDbEntity
    {
        int Id { get; set; }
        bool IsDeleted { get; set; }
    }
 
 public interface IRepository<T, T1>
        where T : class, IDbEntity
        where T1 : class, IDbEntity
    {
        int Add(T1 newEntityViewModel);
        void AddRange(List<T1> newEntities);
        void Remove(int id);
        void RemoveFromDb(int id);
        List<T1> Find(Expression<Func<T1, bool>> predicate);
        T1 FindById(int id);
        List<T1> FindAll();
        T FindByIdInContext(int id);
        int GetNextId();
        List<T> FindAllInContext();
    }
    
    internal class DbRepository<T, T1> : IRepository<T, T1>
        where T : class, IDbEntity
        where T1 : class, IDbEntity
    {
        protected ObjectSet<T> _objectSet;
        protected List<T1> _internalList;
        protected ObjectContext _context;

        public DbRepository(ObjectContext context)
        {
            try
            {
                
                _internalList = new List<T1>();
                _objectSet = context.CreateObjectSet<T>();
                _context = context;
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
                throw;
            }
        }



        public int Add(T1 newEntityViewModel)
        {
            try
            {
                var entityDto = AutoMapperConfiguration.GetMapperConfiguration().Map<T1, T>(newEntityViewModel);
                _objectSet.AddObject(entityDto);

                _context.SaveChanges();
                
                //check id 
                return entityDto.Id;
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
                throw;
            }
        }


        public List<T1> Find(Expression<Func<T1, bool>> predicate)
        {
            try
            {
                var listT1 = AutoMapperConfiguration.GetMapperConfiguration().Map<List<T1>>(_objectSet.Where(q => !q.IsDeleted));
                var result = listT1.Where(predicate.Compile()).ToList();

                return result;
            }
            catch (Exception ex)
            {
               log.Error(ex.Message);
                throw;
            }
        }

        public List<T1> FindAll()
        {
            try
            {
                var listT1 = AutoMapperConfiguration.GetMapperConfiguration().Map<List<T1>>(_objectSet.Where(q => !q.IsDeleted));
                return listT1;
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
                throw;
            }
        }

    }
    
    
    public interface IUnitOfWork
    {
        IRepository<User, User_ViewModel> Users { get; }
        IRepository<Type, Type_ViewModel> Types { get; }
        
        /// and a lot more repositories

        ObjectContext Context { get; }
        void Commit();
    }
    
    
    internal class DbUnitOfWork : IUnitOfWork
    {
        private DbRepository<User, User_ViewModel> _users = null;
        private DbRepository<Type, Type_ViewModel> _types = null;
       
       
       
        private readonly ObjectContext _context;
        private readonly EntityConnection _connectionString;

   
        public ObjectContext Context { get { return _context; } }

        public DbUnitOfWork(EntityConnection connectionString)
        {
            try
            {
                _connectionString = connectionString;
                _context = new ObjectContext(connectionString, true);
                _context.ContextOptions.LazyLoadingEnabled = true;
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
                throw;
            }
        }

        public IRepository<User, User_ViewModel> Users
        {
            get
            {
                return _users ?? (_users = new DbRepository<User, User_ViewModel>(_context));
            }
        }


        public IRepository<Type, Type_ViewModel> Types
        {
            get
            {
                return _types ?? (_types = new DbRepository<Type, Type_ViewModel>(_context));
            }
        }



        public void Commit()
        {
            try
            {
               _context.SaveChanges();

            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
                throw;
            }
        }

    }
    
    DbController.cs
    public partial class DbController
    {
        protected readonly IUnitOfWork _unitOfWork;
        
        protected readonly IRepository<User, User_ViewModel> _userRepository;
        protected readonly IRepository<Type, Type_ViewModel> _typeRepository;
        
        
        public SafeIOController(IUnitOfWork unitOfWork)
        {
           

            _unitOfWork = unitOfWork;
            
            _userRepository = _unitOfWork.Users;
            _typeRepository = _unitOfWork.Types;
            
        }

        public void Save()
        {
            _unitOfWork.Commit();
        }
    }
    Controller_User.cs
    public partial class DbController
    {
       

        public List<User_ViewModel> GetAllUsers()
        {
            try
            {
                
                return _userRepository.FindAll();

            }
            catch (Exception ex)
            {
                _exHandler.LogErrorMessage(Constants_Exception.DB_EXCEPTION_MSG, ex, _exHandler.GetCurrentMethod());
                throw;
            }
        }


        
    }
    
    and then in winforms app 
    
            _unitOfWork = new DbUnitOfWork(connectionString);
            _controller = new DbController(_unitOfWork);

How can I properly implement unitOfWork in order to have the latest information from db inside my context?

jdbc – Close context implicitly in Java EE

I’m trying to implement the following code in Java EE (Java 11) to access a datasource in Wildfly 20. The objective is to close implicitly the JNDI context and the SQL connection:

try (InitialContext context = new InitialContext();
     Connection conn = ((DataSource) context.lookup(pool)).getConnection()) {
    
      // use the connection

} 
catch (NamingException e) {
    logger.error(e.getMessage());
} 
catch (SQLException e) {
    logger.error(e.getMessage());
}

Problem is that context is not closeable, as I get the compilation error:

The resource type InitialContext does not implement java.lang.AutoCloseable

I’m trying to avoid adding finally to close the context, is there a way to achieve this?

google sheets – How to get a value in context of a random filled cell

I have a field which needs to get a random value in context of another random value.

Let’s say I have a random person row
Person has a field with a favorite specific food.

I want to generate a random value for a food type and lookup a specific food.
So the first lookup from a random list is type of food: eg. pizza, and the second loopup is the detailed food, e.g. margarita.

How do I achieve this?

virtual machine – Can the JVM return the content of the context in bytecode?

I am experimenting with NodeJs VM and javascript.

My goal is to reproduce the way Ethereum run smart contract in the EVM.
This is purely educative and experimental.

I am able to compile some javascript into bytecode and run it in a context. I am only testing so I created 3 javascripts.

  1. First script contains my variables declaration and functions.
  2. A setter function that set the value of a variable from step 1 code.
  3. A getter function that return the value of that variable.

These 3 scripts are compiled and run independently in the VM. Now I would like to know how I can retrieve
the bytecode from my VM context that will hold the name.

I want to be able to update the bytecode in step 1 with the variable that was set in step 2.
So next time I run the bytecode it still know about that variable value.

Just like when you call a smart contract to execute some functions. Once you are done, the state get updated.

So after my second step. The state is updated in that VM instance. How can I extract that bytecode out of there and use it as my next reference with the the variable value still present?

How to pass a spring.config.additional-location context parameter to war deployed in websphere 8.5?

I have a spring-boot webapp.war which was developed and deployed to tomcat 8.5, which is configured using a tomcat context file like so:

<?xml version="1.0" encoding="UTF-8"?>
<Context>
    <Parameter name="spring.config.additional-location"
           value="/path/to/additional-location-application.yml"
           />   

</Context>

I’d like to deploy this on an existing websphere 8.5 server, however I am having trouble understanding how I can provide this optional context parameter to the application.

There is a similar question here: https://stackoverflow.com/questions/19968783/how-to-define-context-parameters-in-the-websphere-config-instead-of-the-web-xml

However ideally, I don’t want to modify the original web.xml in the war file. It’s also possible to provide this parameter in the JVM options like -Dspring.config.additional-location=/path/to/additional-location-application.yml however the problem with doing it that way, is that it would affect all the spring boot applications deployed on the same server

Notes:
Suggestion to use environment parameters instead:
https://ibm.software.websphere.application-server.narkive.com/Rcr0kBuU/how-to-define-context-parameters-with-was

context free – CFG for Boolean Expressions with Mandatory Parenthesis

I was recently taught CFG’s and as an exercise, I was told to modify the CFG given in class to now have mandatory parenthesis.

Examples:
(A and B and C) is invalid but (A and (B and C)) and ((A and B) and C) are valid.
(A and notB and C) is invalid but (A and ((notB) and C)) and ((A and (notB)) and C) are valid.
Yes the entire expression must be in parenthesis as well.

The original CFG that was taught in class which is the following.

E -> A
A -> A and B | B
B -> B or C | C
C -> not C | D
D -> (E) | I
I -> T | F

Every attempt I made resulted in an ambiguous grammar or resulted in a language slightly different from the one intended

context free – generating strings from this formal grammar

Hey guys I am having trouble generating strings from this language, I haven’t seen a grammar that looks like this and can’t figure how to generate strings from this grammar, is this Context Sensitive grammar? Thank you.

$G=({S, L_x,R_x,W_x },{a,b},P,S) \
P = {
\S to lambda mid L_x R_x, \
L_x to x mid L_xyW_y, \
W_xy to yW_x, \
W_xR_y to R_yx, \
R_x to x \} \
x, y ∈ {a,b } text{ this means that } x=y text{ but also it can be } x neq y
$