Error reading credential file from location C:\location-path...

1,872 views
Skip to first unread message

Matt Randall

unread,
Jun 14, 2018, 1:38:46 PM6/14/18
to Google Cloud Pub/Sub Discussions
System.InvalidOperationException: 'Error reading credential file from location C:\location-path: Access to the path 'C:\location-path' is denied.
Please check the value of the Environment Variable GOOGLE_APPLICATION_CREDENTIALS'

Just recently started testing and my first time using the google pub/sub platform. I started a c# console app to learn how it works and have run into the error above that happens when it tries to run this piece of code here...

SubscriberServiceApiClient subscriber = SubscriberServiceApiClient.Create();

Whats strange about this is the entire project was working, connecting fine and I was receiveing and reading messages that have been published to the topic.

Has anyone run into this kind of error before and knows what has happened? I've changed none of my code, the error just started occuring. 

I have also double checked the environment variable and also tried changing its location, neither fix worked and resulted in the same error.


            SubscriptionName subName = new SubscriptionName(_projectId, _subscriptionId);           

            try
            {
                SubscriberServiceApiClient subscriber = SubscriberServiceApiClient.Create(); //This is where the error started happening

                var response = subscriber.Pull(subName, true, 10);

                var allMessages = response.ReceivedMessages;

                foreach (ReceivedMessage message in allMessages)
                {
                    String id = message.Message.MessageId;
                    String publishDate = message.Message.PublishTime.ToDateTime().ToString("dd-M-yyyy HH:MM:ss");
                    String data = message.Message.Data.ToStringUtf8();

                    TestLeadClass testing = Newtonsoft.Json.JsonConvert.DeserializeObject<TestLeadClass>(data);

                    Console.WriteLine(id);
                    Console.WriteLine(publishDate);
                    Console.WriteLine(testing.DisplayFullName() + testing.emptyStringTest);
                }
                return response;
            }
            catch (RpcException e)
            {
                Console.WriteLine("Its Broken: " + e);
                return null;
            }


Structure of the TestLeadClass just in case.

    class TestLeadClass
    {
        public String firstname { get; set; }
        public String LastName { get; set; }
        public String emptyStringTest { get; set; }

        public String DisplayFullName()
        {
            String fullName = "";

            fullName = firstname + " " + LastName;

            return fullName;
        }
    }


Kir Titievsky

unread,
Jun 14, 2018, 3:33:22 PM6/14/18
to mattra...@gmail.com, Google Cloud Pub/Sub Discussions
Matt, this seems like an issue with the authentication layer, which is not specific to Pub/Sub. I suspect the shortest path to success here might be to post this as a bug on the .NET client library GitHub issue tracker.

--
You received this message because you are subscribed to the Google Groups "Google Cloud Pub/Sub Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-pubsub-dis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cloud-pubsub-discuss/34821425-c3bf-48c8-9e0a-945dba33f714%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Kir Titievsky | Product Manager | Google Cloud Pub/Sub 

George (Cloud Platform Support)

unread,
Jun 14, 2018, 7:01:24 PM6/14/18
to Google Cloud Pub/Sub Discussions
Hello Matt, 

What version of Visual Studio do you use? The latest version of Json.NET is Version 11.0.2. Is this the one in use at the moment? Have you updated Json.NET lately? 

Matt Randall

unread,
Jun 20, 2018, 9:54:47 AM6/20/18
to Google Cloud Pub/Sub Discussions
Ill take a look and see, didnt think of this to be honest.

Matt Randall

unread,
Jun 20, 2018, 9:55:09 AM6/20/18
to Google Cloud Pub/Sub Discussions
Ill give that a go and see what comes up, thanks.
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-pubsub-discuss+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages