Failed to create AmazonGameLiftClient in Unity3d
up vote
3
down vote
favorite
I use below code to create GameClient in Unity3d:
AmazonGameLiftClient client =
new AmazonGameLiftClient("accessKeyId",
"accessKey",
RegionEndpoint.CNNorth1);
Above code is the first line in Awake(), no any other leading codes.
I get below error:
NullReferenceException: Object reference not set to an instance of an object
Amazon.CSMSection.get_CSMEnabled ()
Amazon.Util.CSMConfig.Configure (Amazon.CSMSection section)
Amazon.Util.Internal.RootConfig..ctor ()
Amazon.AWSConfigs..cctor ()
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for Amazon.AWSConfigs
Amazon.Runtime.ClientConfig..ctor ()
Amazon.GameLift.AmazonGameLiftConfig..ctor ()
Amazon.GameLift.AmazonGameLiftClient..ctor (System.String awsAccessKeyId, System.String awsSecretAccessKey, Amazon.RegionEndpoint region)
Is there anything I forgot to do?
I assume the root cause is I do not put app.config in the correct place.
So AWS SDK does not init correctly, but I have not found any tutorial for using Unity3d as Amazon GameLift client :(
My Environment:
- OS: Mac OS X 10.14.1
- Unity3d: 2018.2.12f1
- AWS SDK Core: 3.3.29.10(.net35)
- AWS SDK GameLift: 3.3.12.29(.net35)
Update:
The AWS SDK relies on System.ConfigurationManager which seems not available in Unity3d projects. It seems the root cause of the NullReferenceException.
amazon-web-services unity3d aws-sdk aws-sdk-net amazon-gamelift
add a comment |
up vote
3
down vote
favorite
I use below code to create GameClient in Unity3d:
AmazonGameLiftClient client =
new AmazonGameLiftClient("accessKeyId",
"accessKey",
RegionEndpoint.CNNorth1);
Above code is the first line in Awake(), no any other leading codes.
I get below error:
NullReferenceException: Object reference not set to an instance of an object
Amazon.CSMSection.get_CSMEnabled ()
Amazon.Util.CSMConfig.Configure (Amazon.CSMSection section)
Amazon.Util.Internal.RootConfig..ctor ()
Amazon.AWSConfigs..cctor ()
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for Amazon.AWSConfigs
Amazon.Runtime.ClientConfig..ctor ()
Amazon.GameLift.AmazonGameLiftConfig..ctor ()
Amazon.GameLift.AmazonGameLiftClient..ctor (System.String awsAccessKeyId, System.String awsSecretAccessKey, Amazon.RegionEndpoint region)
Is there anything I forgot to do?
I assume the root cause is I do not put app.config in the correct place.
So AWS SDK does not init correctly, but I have not found any tutorial for using Unity3d as Amazon GameLift client :(
My Environment:
- OS: Mac OS X 10.14.1
- Unity3d: 2018.2.12f1
- AWS SDK Core: 3.3.29.10(.net35)
- AWS SDK GameLift: 3.3.12.29(.net35)
Update:
The AWS SDK relies on System.ConfigurationManager which seems not available in Unity3d projects. It seems the root cause of the NullReferenceException.
amazon-web-services unity3d aws-sdk aws-sdk-net amazon-gamelift
First of all, the error gives all the details to debug it. Second, Google gives you the answers. This will help you understanding the issue -> stackoverflow.com/questions/4660142/…
– Cabrra
Nov 22 at 14:09
This seems like a configuration issue; please provide the following details: Name the AWS SDK nuget packages you're using and which version they are on. Name the .NET framework you're on and which version it is. Any other relevant code leading up to this point or any other references you've made to the AWS SDK that executed up to this point would also be helpful for context. In the interim, make sure you're using the correct AWS SDK packages for your framework and that they are with the latest version. Also make sure you're using the correct AccessKey/SecretKey.
– Anthony Neace
Nov 22 at 16:32
@AnthonyNeace you are right. It should be a configuration issue. I have no idea where to put the app.config in a Unity3d project. I am trying to figure it out.
– Yongyi
Nov 24 at 3:26
I'm experiencing this issue as well after upgrading the aws sdk. @AnthonyNeace this is entry point to the api. You make a config before making a client to do other things so there is no other context. Cabrra's comment is also really shallow and unhelpful. This NRE happens within the default constructor of the config classes so there must be some kind of non-obvious external setup that needs to be done now. Perhaps some kind of factory method?
– Jayd16
Nov 28 at 23:49
add a comment |
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I use below code to create GameClient in Unity3d:
AmazonGameLiftClient client =
new AmazonGameLiftClient("accessKeyId",
"accessKey",
RegionEndpoint.CNNorth1);
Above code is the first line in Awake(), no any other leading codes.
I get below error:
NullReferenceException: Object reference not set to an instance of an object
Amazon.CSMSection.get_CSMEnabled ()
Amazon.Util.CSMConfig.Configure (Amazon.CSMSection section)
Amazon.Util.Internal.RootConfig..ctor ()
Amazon.AWSConfigs..cctor ()
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for Amazon.AWSConfigs
Amazon.Runtime.ClientConfig..ctor ()
Amazon.GameLift.AmazonGameLiftConfig..ctor ()
Amazon.GameLift.AmazonGameLiftClient..ctor (System.String awsAccessKeyId, System.String awsSecretAccessKey, Amazon.RegionEndpoint region)
Is there anything I forgot to do?
I assume the root cause is I do not put app.config in the correct place.
So AWS SDK does not init correctly, but I have not found any tutorial for using Unity3d as Amazon GameLift client :(
My Environment:
- OS: Mac OS X 10.14.1
- Unity3d: 2018.2.12f1
- AWS SDK Core: 3.3.29.10(.net35)
- AWS SDK GameLift: 3.3.12.29(.net35)
Update:
The AWS SDK relies on System.ConfigurationManager which seems not available in Unity3d projects. It seems the root cause of the NullReferenceException.
amazon-web-services unity3d aws-sdk aws-sdk-net amazon-gamelift
I use below code to create GameClient in Unity3d:
AmazonGameLiftClient client =
new AmazonGameLiftClient("accessKeyId",
"accessKey",
RegionEndpoint.CNNorth1);
Above code is the first line in Awake(), no any other leading codes.
I get below error:
NullReferenceException: Object reference not set to an instance of an object
Amazon.CSMSection.get_CSMEnabled ()
Amazon.Util.CSMConfig.Configure (Amazon.CSMSection section)
Amazon.Util.Internal.RootConfig..ctor ()
Amazon.AWSConfigs..cctor ()
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for Amazon.AWSConfigs
Amazon.Runtime.ClientConfig..ctor ()
Amazon.GameLift.AmazonGameLiftConfig..ctor ()
Amazon.GameLift.AmazonGameLiftClient..ctor (System.String awsAccessKeyId, System.String awsSecretAccessKey, Amazon.RegionEndpoint region)
Is there anything I forgot to do?
I assume the root cause is I do not put app.config in the correct place.
So AWS SDK does not init correctly, but I have not found any tutorial for using Unity3d as Amazon GameLift client :(
My Environment:
- OS: Mac OS X 10.14.1
- Unity3d: 2018.2.12f1
- AWS SDK Core: 3.3.29.10(.net35)
- AWS SDK GameLift: 3.3.12.29(.net35)
Update:
The AWS SDK relies on System.ConfigurationManager which seems not available in Unity3d projects. It seems the root cause of the NullReferenceException.
amazon-web-services unity3d aws-sdk aws-sdk-net amazon-gamelift
amazon-web-services unity3d aws-sdk aws-sdk-net amazon-gamelift
edited Dec 2 at 7:45
asked Nov 22 at 13:29
Yongyi
166
166
First of all, the error gives all the details to debug it. Second, Google gives you the answers. This will help you understanding the issue -> stackoverflow.com/questions/4660142/…
– Cabrra
Nov 22 at 14:09
This seems like a configuration issue; please provide the following details: Name the AWS SDK nuget packages you're using and which version they are on. Name the .NET framework you're on and which version it is. Any other relevant code leading up to this point or any other references you've made to the AWS SDK that executed up to this point would also be helpful for context. In the interim, make sure you're using the correct AWS SDK packages for your framework and that they are with the latest version. Also make sure you're using the correct AccessKey/SecretKey.
– Anthony Neace
Nov 22 at 16:32
@AnthonyNeace you are right. It should be a configuration issue. I have no idea where to put the app.config in a Unity3d project. I am trying to figure it out.
– Yongyi
Nov 24 at 3:26
I'm experiencing this issue as well after upgrading the aws sdk. @AnthonyNeace this is entry point to the api. You make a config before making a client to do other things so there is no other context. Cabrra's comment is also really shallow and unhelpful. This NRE happens within the default constructor of the config classes so there must be some kind of non-obvious external setup that needs to be done now. Perhaps some kind of factory method?
– Jayd16
Nov 28 at 23:49
add a comment |
First of all, the error gives all the details to debug it. Second, Google gives you the answers. This will help you understanding the issue -> stackoverflow.com/questions/4660142/…
– Cabrra
Nov 22 at 14:09
This seems like a configuration issue; please provide the following details: Name the AWS SDK nuget packages you're using and which version they are on. Name the .NET framework you're on and which version it is. Any other relevant code leading up to this point or any other references you've made to the AWS SDK that executed up to this point would also be helpful for context. In the interim, make sure you're using the correct AWS SDK packages for your framework and that they are with the latest version. Also make sure you're using the correct AccessKey/SecretKey.
– Anthony Neace
Nov 22 at 16:32
@AnthonyNeace you are right. It should be a configuration issue. I have no idea where to put the app.config in a Unity3d project. I am trying to figure it out.
– Yongyi
Nov 24 at 3:26
I'm experiencing this issue as well after upgrading the aws sdk. @AnthonyNeace this is entry point to the api. You make a config before making a client to do other things so there is no other context. Cabrra's comment is also really shallow and unhelpful. This NRE happens within the default constructor of the config classes so there must be some kind of non-obvious external setup that needs to be done now. Perhaps some kind of factory method?
– Jayd16
Nov 28 at 23:49
First of all, the error gives all the details to debug it. Second, Google gives you the answers. This will help you understanding the issue -> stackoverflow.com/questions/4660142/…
– Cabrra
Nov 22 at 14:09
First of all, the error gives all the details to debug it. Second, Google gives you the answers. This will help you understanding the issue -> stackoverflow.com/questions/4660142/…
– Cabrra
Nov 22 at 14:09
This seems like a configuration issue; please provide the following details: Name the AWS SDK nuget packages you're using and which version they are on. Name the .NET framework you're on and which version it is. Any other relevant code leading up to this point or any other references you've made to the AWS SDK that executed up to this point would also be helpful for context. In the interim, make sure you're using the correct AWS SDK packages for your framework and that they are with the latest version. Also make sure you're using the correct AccessKey/SecretKey.
– Anthony Neace
Nov 22 at 16:32
This seems like a configuration issue; please provide the following details: Name the AWS SDK nuget packages you're using and which version they are on. Name the .NET framework you're on and which version it is. Any other relevant code leading up to this point or any other references you've made to the AWS SDK that executed up to this point would also be helpful for context. In the interim, make sure you're using the correct AWS SDK packages for your framework and that they are with the latest version. Also make sure you're using the correct AccessKey/SecretKey.
– Anthony Neace
Nov 22 at 16:32
@AnthonyNeace you are right. It should be a configuration issue. I have no idea where to put the app.config in a Unity3d project. I am trying to figure it out.
– Yongyi
Nov 24 at 3:26
@AnthonyNeace you are right. It should be a configuration issue. I have no idea where to put the app.config in a Unity3d project. I am trying to figure it out.
– Yongyi
Nov 24 at 3:26
I'm experiencing this issue as well after upgrading the aws sdk. @AnthonyNeace this is entry point to the api. You make a config before making a client to do other things so there is no other context. Cabrra's comment is also really shallow and unhelpful. This NRE happens within the default constructor of the config classes so there must be some kind of non-obvious external setup that needs to be done now. Perhaps some kind of factory method?
– Jayd16
Nov 28 at 23:49
I'm experiencing this issue as well after upgrading the aws sdk. @AnthonyNeace this is entry point to the api. You make a config before making a client to do other things so there is no other context. Cabrra's comment is also really shallow and unhelpful. This NRE happens within the default constructor of the config classes so there must be some kind of non-obvious external setup that needs to be done now. Perhaps some kind of factory method?
– Jayd16
Nov 28 at 23:49
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
After googling a lot, It seems the only way to resolve this problem is using reflection.
The root cause of the exception is when creating a GameLiftClient, AWS SDK tries to get AWSConfig from app.config. But there is no app.config in a Unity3d project.
So my solution is injecting one to the ConfigurationManager.
Below is the code:
String path = Path.Combine(Application.dataPath, "aws.config");
ExeConfigurationFileMap configMap =
new ExeConfigurationFileMap {ExeConfigFilename = path};
Configuration awsConfig = ConfigurationManager
.OpenMappedExeConfiguration(configMap, ConfigurationUserLevel.None);
Type type = typeof(ConfigurationManager).Assembly
.GetType("System.Configuration.ClientConfigurationSystem");
var clientConfigSystem = Activator.CreateInstance(type, true);
type.GetField("cfg", BindingFlags.NonPublic | BindingFlags.Instance)
.SetValue(clientConfigSystem, awsConfig);
typeof(ConfigurationManager)
.GetField("configSystem",
BindingFlags.Static | BindingFlags.NonPublic)
.SetValue(null,
clientConfigSystem);
And place the "aws.config" under Assets directory of Unity3d Project.
Below is my "aws.config":
<configuration>
<configSections>
<section name="aws" type="Amazon.AWSSection, AWSSDK.Core"/>
<section name="system.diagnostics" type="System.Diagnostics.DiagnosticsConfigurationHandler" />
</configSections>
<aws>
<logging logTo="Log4Net"/>
<csmConfig csmEnabled="false"/>
</aws>
<system.diagnostics>
<trace autoflush="true" />
</system.diagnostics>
</configuration>
Then I can create the AmazonGameLiftClient successfully.
The fields name used in reflection may be different if you use another version of the ".Net Framework".
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
After googling a lot, It seems the only way to resolve this problem is using reflection.
The root cause of the exception is when creating a GameLiftClient, AWS SDK tries to get AWSConfig from app.config. But there is no app.config in a Unity3d project.
So my solution is injecting one to the ConfigurationManager.
Below is the code:
String path = Path.Combine(Application.dataPath, "aws.config");
ExeConfigurationFileMap configMap =
new ExeConfigurationFileMap {ExeConfigFilename = path};
Configuration awsConfig = ConfigurationManager
.OpenMappedExeConfiguration(configMap, ConfigurationUserLevel.None);
Type type = typeof(ConfigurationManager).Assembly
.GetType("System.Configuration.ClientConfigurationSystem");
var clientConfigSystem = Activator.CreateInstance(type, true);
type.GetField("cfg", BindingFlags.NonPublic | BindingFlags.Instance)
.SetValue(clientConfigSystem, awsConfig);
typeof(ConfigurationManager)
.GetField("configSystem",
BindingFlags.Static | BindingFlags.NonPublic)
.SetValue(null,
clientConfigSystem);
And place the "aws.config" under Assets directory of Unity3d Project.
Below is my "aws.config":
<configuration>
<configSections>
<section name="aws" type="Amazon.AWSSection, AWSSDK.Core"/>
<section name="system.diagnostics" type="System.Diagnostics.DiagnosticsConfigurationHandler" />
</configSections>
<aws>
<logging logTo="Log4Net"/>
<csmConfig csmEnabled="false"/>
</aws>
<system.diagnostics>
<trace autoflush="true" />
</system.diagnostics>
</configuration>
Then I can create the AmazonGameLiftClient successfully.
The fields name used in reflection may be different if you use another version of the ".Net Framework".
add a comment |
up vote
0
down vote
accepted
After googling a lot, It seems the only way to resolve this problem is using reflection.
The root cause of the exception is when creating a GameLiftClient, AWS SDK tries to get AWSConfig from app.config. But there is no app.config in a Unity3d project.
So my solution is injecting one to the ConfigurationManager.
Below is the code:
String path = Path.Combine(Application.dataPath, "aws.config");
ExeConfigurationFileMap configMap =
new ExeConfigurationFileMap {ExeConfigFilename = path};
Configuration awsConfig = ConfigurationManager
.OpenMappedExeConfiguration(configMap, ConfigurationUserLevel.None);
Type type = typeof(ConfigurationManager).Assembly
.GetType("System.Configuration.ClientConfigurationSystem");
var clientConfigSystem = Activator.CreateInstance(type, true);
type.GetField("cfg", BindingFlags.NonPublic | BindingFlags.Instance)
.SetValue(clientConfigSystem, awsConfig);
typeof(ConfigurationManager)
.GetField("configSystem",
BindingFlags.Static | BindingFlags.NonPublic)
.SetValue(null,
clientConfigSystem);
And place the "aws.config" under Assets directory of Unity3d Project.
Below is my "aws.config":
<configuration>
<configSections>
<section name="aws" type="Amazon.AWSSection, AWSSDK.Core"/>
<section name="system.diagnostics" type="System.Diagnostics.DiagnosticsConfigurationHandler" />
</configSections>
<aws>
<logging logTo="Log4Net"/>
<csmConfig csmEnabled="false"/>
</aws>
<system.diagnostics>
<trace autoflush="true" />
</system.diagnostics>
</configuration>
Then I can create the AmazonGameLiftClient successfully.
The fields name used in reflection may be different if you use another version of the ".Net Framework".
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
After googling a lot, It seems the only way to resolve this problem is using reflection.
The root cause of the exception is when creating a GameLiftClient, AWS SDK tries to get AWSConfig from app.config. But there is no app.config in a Unity3d project.
So my solution is injecting one to the ConfigurationManager.
Below is the code:
String path = Path.Combine(Application.dataPath, "aws.config");
ExeConfigurationFileMap configMap =
new ExeConfigurationFileMap {ExeConfigFilename = path};
Configuration awsConfig = ConfigurationManager
.OpenMappedExeConfiguration(configMap, ConfigurationUserLevel.None);
Type type = typeof(ConfigurationManager).Assembly
.GetType("System.Configuration.ClientConfigurationSystem");
var clientConfigSystem = Activator.CreateInstance(type, true);
type.GetField("cfg", BindingFlags.NonPublic | BindingFlags.Instance)
.SetValue(clientConfigSystem, awsConfig);
typeof(ConfigurationManager)
.GetField("configSystem",
BindingFlags.Static | BindingFlags.NonPublic)
.SetValue(null,
clientConfigSystem);
And place the "aws.config" under Assets directory of Unity3d Project.
Below is my "aws.config":
<configuration>
<configSections>
<section name="aws" type="Amazon.AWSSection, AWSSDK.Core"/>
<section name="system.diagnostics" type="System.Diagnostics.DiagnosticsConfigurationHandler" />
</configSections>
<aws>
<logging logTo="Log4Net"/>
<csmConfig csmEnabled="false"/>
</aws>
<system.diagnostics>
<trace autoflush="true" />
</system.diagnostics>
</configuration>
Then I can create the AmazonGameLiftClient successfully.
The fields name used in reflection may be different if you use another version of the ".Net Framework".
After googling a lot, It seems the only way to resolve this problem is using reflection.
The root cause of the exception is when creating a GameLiftClient, AWS SDK tries to get AWSConfig from app.config. But there is no app.config in a Unity3d project.
So my solution is injecting one to the ConfigurationManager.
Below is the code:
String path = Path.Combine(Application.dataPath, "aws.config");
ExeConfigurationFileMap configMap =
new ExeConfigurationFileMap {ExeConfigFilename = path};
Configuration awsConfig = ConfigurationManager
.OpenMappedExeConfiguration(configMap, ConfigurationUserLevel.None);
Type type = typeof(ConfigurationManager).Assembly
.GetType("System.Configuration.ClientConfigurationSystem");
var clientConfigSystem = Activator.CreateInstance(type, true);
type.GetField("cfg", BindingFlags.NonPublic | BindingFlags.Instance)
.SetValue(clientConfigSystem, awsConfig);
typeof(ConfigurationManager)
.GetField("configSystem",
BindingFlags.Static | BindingFlags.NonPublic)
.SetValue(null,
clientConfigSystem);
And place the "aws.config" under Assets directory of Unity3d Project.
Below is my "aws.config":
<configuration>
<configSections>
<section name="aws" type="Amazon.AWSSection, AWSSDK.Core"/>
<section name="system.diagnostics" type="System.Diagnostics.DiagnosticsConfigurationHandler" />
</configSections>
<aws>
<logging logTo="Log4Net"/>
<csmConfig csmEnabled="false"/>
</aws>
<system.diagnostics>
<trace autoflush="true" />
</system.diagnostics>
</configuration>
Then I can create the AmazonGameLiftClient successfully.
The fields name used in reflection may be different if you use another version of the ".Net Framework".
edited Dec 2 at 9:07
answered Dec 2 at 7:26
Yongyi
166
166
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53432086%2ffailed-to-create-amazongameliftclient-in-unity3d%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
First of all, the error gives all the details to debug it. Second, Google gives you the answers. This will help you understanding the issue -> stackoverflow.com/questions/4660142/…
– Cabrra
Nov 22 at 14:09
This seems like a configuration issue; please provide the following details: Name the AWS SDK nuget packages you're using and which version they are on. Name the .NET framework you're on and which version it is. Any other relevant code leading up to this point or any other references you've made to the AWS SDK that executed up to this point would also be helpful for context. In the interim, make sure you're using the correct AWS SDK packages for your framework and that they are with the latest version. Also make sure you're using the correct AccessKey/SecretKey.
– Anthony Neace
Nov 22 at 16:32
@AnthonyNeace you are right. It should be a configuration issue. I have no idea where to put the app.config in a Unity3d project. I am trying to figure it out.
– Yongyi
Nov 24 at 3:26
I'm experiencing this issue as well after upgrading the aws sdk. @AnthonyNeace this is entry point to the api. You make a config before making a client to do other things so there is no other context. Cabrra's comment is also really shallow and unhelpful. This NRE happens within the default constructor of the config classes so there must be some kind of non-obvious external setup that needs to be done now. Perhaps some kind of factory method?
– Jayd16
Nov 28 at 23:49