“An error occurred while processing the request: Cannot perform runtime binding on a null reference.”
An error occurred while using an add-in by calling the Gemini API in a program called Autodesk Revit. Previously, it had been running without any issues, but now the error appears as shown above. The versions are Gemini-2.5-pro and Gemini-3-pro-preview.
// [MODIFIED] CallGeminiApiAsync 수정
private async Task CallGeminiApiAsync(string prompt)
{
string apiKey = GetApiKey(); // 기존 GetApiKey() 메서드 사용
string modelName = “gemini-2.5-flash”; // [MODIFIED] 2.5 flash로 변경 (속도 및 성능)
var uri = new Uri($“https://generativelanguage.googleapis.com/v1beta/models/{modelName}:generateContent?key={apiKey}”);
// [MODIFIED] SystemInstruction 수정 (단일 객체 -> JSON 배열 반환)
string systemInstruction = @"You are a helpful Revit BIM AI Assistant.