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 7068263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:18:09+00:00 2026-05-28T05:18:09+00:00

I want to add named data cache programmatically in appfabric. I kept following code

  • 0

I want to add named data cache programmatically in appfabric.
I kept following code for this :-

    try
    {
        //This can also be kept in a config file
        var config = new DataCacheFactoryConfiguration();
        config.SecurityProperties = new DataCacheSecurity();

        config.Servers = new List<DataCacheServerEndpoint> { new DataCacheServerEndpoint(Environment.MachineName, 22233) };

        DataCacheFactory dcf = new DataCacheFactory(config);

        if (dcf != null)
        {
            var state = InitialSessionState.CreateDefault();
            state.ImportPSModule(new string[] { "DistributedCacheAdministration", "DistributedCacheConfiguration" });
            state.ThrowOnRunspaceOpenError = true;
            var rs = RunspaceFactory.CreateRunspace(state);
            rs.Open();
            var pipe = rs.CreatePipeline();
            pipe.Commands.Add(new Command("Use-CacheCluster"));

            var cmd = new Command("New-Cache");
            cmd.Parameters.Add(new CommandParameter("Name", "Vaibhav"));

            cmd.Parameters.Add(new CommandParameter("Expirable", false));
            pipe.Commands.Add(cmd);

            var output = pipe.Invoke();
        }
    }
    catch (Exception e)
    {
        //throw new Exception 
    }

But this is not working as expected when i try to access the DataCache (using: dcf.GetCache("Vaibhav");) it is giving Cache not found error. When i created the Cache using powershell it worked fine and i was able to access the Cache, but i want to implement this programmactically and not by Command Prompt(powershell)

Please suggest a proper way to implement this….

Thanks in Advance
Vaibhav

  • 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-28T05:18:09+00:00Added an answer on May 28, 2026 at 5:18 am

    You actually have to Start the Visual Studio as admin to be able to create Cache programatically.

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

Sidebar

Related Questions

I have a wx.ListView box named lvActions that I add data to using code
I want to store data from form named adding in an array - I
I am newer for php. I want make php page cache, query data from
I want to design a data structure with the following properties: Accessible as a
I have problem with remove() method. I can't remove $(this) object. My code is:
I'm want to add a parameter named foo to the request that fullcalendar submits
I want to add 10 buttons to Tkinter, named One to Ten. I basically
I want to add a string to a variable name that represents an integer.
I have dbml with single table users i want add partial class for User
I have a website built with ASP.NET (3.5) and want add some level of

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.